diff --git a/src/CreditCard.php b/src/CreditCard.php index 1ca4660..232c772 100644 --- a/src/CreditCard.php +++ b/src/CreditCard.php @@ -43,7 +43,7 @@ class CreditCard * * @return void */ - public function __construct(string $number, string $expiry, int $crypt = 7) + public function __construct($number = '', $expiry = '', $crypt = 7) { $this->number = $number; $this->expiry = $expiry; @@ -73,7 +73,7 @@ public function attach(Customer $customer) * * @return $this */ - public static function create(string $number, string $expiry, int $crypt = 7) + public static function create($number = '', $expiry = '', $crypt = 7) { return new static($number, $expiry, $crypt); } diff --git a/src/Customer.php b/src/Customer.php index 18a4b8a..dc79617 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -51,10 +51,10 @@ class Customer */ public function __construct(array $params = []) { - $this->id = $params['id'] ?? null; - $this->email = $params['email'] ?? null; - $this->phone = $params['phone'] ?? null; - $this->note = $params['note'] ?? null; + $this->id = isset($params['id']) ? $params['id'] : null; + $this->email = isset($params['email']) ? $params['email'] : null; + $this->phone = isset($params['phone']) ? $params['phone'] : null; + $this->note = isset($params['note']) ? $params['note'] : null; } /** diff --git a/src/Gateway.php b/src/Gateway.php index 55c5f91..2d3d3b7 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -80,7 +80,7 @@ class Gateway * * @return void */ - public function __construct(string $id, string $token, string $environment) + public function __construct($id = '', $token = '', $environment = '') { $this->id = $id; $this->token = $token; @@ -96,11 +96,11 @@ public function __construct(string $id, string $token, string $environment) * * @return \CraigPaul\Moneris\Response */ - public function capture($transaction, string $order = null, $amount = null) + public function capture($transaction, $order = null, $amount = null) { if ($transaction instanceof Transaction) { $order = $transaction->order(); - $amount = $amount ?? $transaction->amount(); + $amount = !is_null($amount) ? $amount : $transaction->amount(); $transaction = $transaction->number(); } @@ -198,11 +198,11 @@ protected function process(Transaction $transaction) * * @return \CraigPaul\Moneris\Response */ - public function refund($transaction, string $order = null, $amount = null) + public function refund($transaction, $order = null, $amount = null) { if ($transaction instanceof Transaction) { $order = $transaction->order(); - $amount = $amount ?? $transaction->amount(); + $amount = !is_null($amount) ? $amount : $transaction->amount(); $transaction = $transaction->number(); } @@ -262,7 +262,7 @@ public function verify(array $params = []) * * @return \CraigPaul\Moneris\Response */ - public function void($transaction, string $order = null) + public function void($transaction, $order = null) { if ($transaction instanceof Transaction) { $order = $transaction->order(); diff --git a/src/Moneris.php b/src/Moneris.php index 571248d..a53e7fb 100644 --- a/src/Moneris.php +++ b/src/Moneris.php @@ -55,11 +55,11 @@ class Moneris * * @return void */ - public function __construct(string $id, string $token, array $params = []) + public function __construct($id = '', $token = '', array $params = []) { $this->id = $id; $this->token = $token; - $this->environment = $params['environment'] ?? self::ENV_LIVE; + $this->environment = isset($params['environment']) ? $params['environment'] : self::ENV_LIVE; $this->params = $params; } @@ -72,7 +72,7 @@ public function __construct(string $id, string $token, array $params = []) * * @return \CraigPaul\Moneris\Gateway */ - public static function create(string $id, string $token, array $params = []) + public static function create($id = '', $token = '', array $params = []) { $moneris = new static($id, $token, $params); diff --git a/src/Processor.php b/src/Processor.php index 17b2ce7..1c3808f 100644 --- a/src/Processor.php +++ b/src/Processor.php @@ -49,7 +49,7 @@ public function __construct(Client $client) * * @return array */ - public function config(string $environment) + public function config($environment = '') { if ($environment === Moneris::ENV_LIVE) { $this->config['host'] = 'www3.moneris.com'; @@ -101,7 +101,7 @@ protected function error() * * @return string */ - protected function send(array $config, string $url, string $xml) + protected function send(array $config, $url = '', $xml = '') { $response = $this->client->post($url, [ 'body' => $xml, diff --git a/src/Receipt.php b/src/Receipt.php index 0bd6b39..77b7c61 100644 --- a/src/Receipt.php +++ b/src/Receipt.php @@ -92,7 +92,7 @@ protected function prepare($data) * * @return mixed|null */ - public function read(string $value) + public function read($value = '') { if (isset($this->data[$value]) && !is_null($this->data[$value])) { return $this->data[$value]; @@ -116,8 +116,8 @@ private function setData(array $data) 'email' => isset($data['email']) ? $data['email']->__toString() : '', 'note' => isset($data['note']) ? $data['note']->__toString() : '', 'crypt' => isset($data['crypt_type']) ? intval($data['crypt_type']) : null, - 'masked_pan' => $data['masked_pan'] ?? null, - 'pan' => $data['pan'] ?? null, + 'masked_pan' => isset($data['masked_pan']) ? $data['masked_pan'] : null, + 'pan' => isset($data['pan']) ? $data['pan'] : null, 'expiry_date' => [ 'month' => isset($data['expdate']) ? substr($data['expdate'], -2, 2) : null, 'year' => isset($data['expdate']) ? substr($data['expdate'], 0, 2) : null, diff --git a/src/Response.php b/src/Response.php index 5032e56..792458e 100644 --- a/src/Response.php +++ b/src/Response.php @@ -192,7 +192,7 @@ public function validate() return $this; } - $code = $receipt->read('avs_result') ?? false; + $code = !is_null($receipt->read('avs_result')) ? $receipt->read('avs_result') : false; if ($gateway->avs && $code && $code !== 'null' && !in_array($code, $gateway->avsCodes)) { switch ($code) { @@ -224,7 +224,7 @@ public function validate() return $this; } - $code = $receipt->read('cvd_result') ?? null; + $code = !is_null($receipt->read('cvd_result')) ? $receipt->read('cvd_result') : null; if ($gateway->avs && !is_null($code) && $code !== 'null' && !in_array($code{1}, $gateway->cvdCodes)) { $this->status = Response::CVD; diff --git a/src/Transaction.php b/src/Transaction.php index ba04176..a90a2a8 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -203,7 +203,7 @@ public function valid() $params = $this->params; $errors = []; - $errors[] = Validator::empty($params) ? 'No parameters provided.' : null; + $errors[] = Validator::isEmpty($params) ? 'No parameters provided.' : null; if (isset($params['type'])) { switch ($params['type']) { diff --git a/src/Validator.php b/src/Validator.php index d5f8fa6..6c4d9fa 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -9,7 +9,7 @@ class Validator * * @return bool */ - public static function empty(array $array = []) + public static function isEmpty(array $array = []) { return empty($array); } @@ -20,7 +20,7 @@ public static function empty(array $array = []) * * @return bool */ - public static function set(array $array, string $key) + public static function set(array $array, $key = '') { return isset($array[$key]); } diff --git a/src/Vault.php b/src/Vault.php index 317deb9..2602bdc 100644 --- a/src/Vault.php +++ b/src/Vault.php @@ -22,7 +22,7 @@ class Vault extends Gateway * * @return void */ - public function __construct(string $id, string $token, string $environment) + public function __construct($id = '', $token = '', $environment = '') { parent::__construct($id, $token, $environment); } @@ -57,7 +57,7 @@ public function add(CreditCard $card) * * @return $this */ - public static function create(string $id, string $token, string $environment) + public static function create($id = '', $token = '', $environment = '') { return new static($id, $token, $environment); } @@ -69,7 +69,7 @@ public static function create(string $id, string $token, string $environment) * * @return \CraigPaul\Moneris\Response */ - public function delete(string $key) + public function delete($key = '') { $params = [ 'type' => 'res_delete', @@ -104,7 +104,7 @@ public function expiring() * * @return \CraigPaul\Moneris\Response */ - public function peek(string $key, bool $full = false) + public function peek($key = '', $full = false) { $params = [ 'type' => $full ? 'res_lookup_full' : 'res_lookup_masked', @@ -163,7 +163,7 @@ public function purchase(array $params = []) * * @return \CraigPaul\Moneris\Response */ - public function tokenize($transaction, string $order = null) + public function tokenize($transaction, $order = null) { if ($transaction instanceof Transaction) { $order = $transaction->order(); @@ -189,7 +189,7 @@ public function tokenize($transaction, string $order = null) * * @return \CraigPaul\Moneris\Response */ - public function update(string $key, CreditCard $card) + public function update($key = '', CreditCard $card) { $params = [ 'type' => 'res_update_cc',