Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Removes all php7 references for 5.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 25, 2016
1 parent 78200b2 commit a69e6a1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/Moneris.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/Receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
4 changes: 2 additions & 2 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Validator
*
* @return bool
*/
public static function empty(array $array = [])
public static function isEmpty(array $array = [])
{
return empty($array);
}
Expand All @@ -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]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand All @@ -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',
Expand Down

0 comments on commit a69e6a1

Please sign in to comment.