Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Jan 19, 2024
1 parent 2022c2c commit 3e6dfdb
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 23 deletions.
22 changes: 22 additions & 0 deletions src/PayPal/Order/Comparator/PayPalOrderComparator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\Comparator;

use PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject\PayPalOrder;
Expand Down Expand Up @@ -46,12 +65,14 @@ private function compareValues($value1, $value2)
} else {
$result |= $value1 !== $value2;
}

return $result;
}

/**
* @param array $array1
* @param array $array2
*
* @return false|int|string
*/
private function compareArraysDeep($array1, $array2)
Expand All @@ -70,6 +91,7 @@ private function compareArraysDeep($array1, $array2)
$result |= $oldValue !== $newValue;
}
}

return $result;
}
}
25 changes: 22 additions & 3 deletions src/PayPal/Order/ValueObject/PayPalOrder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject;

use PrestaShop\Module\PrestashopCheckout\Order\ValueObject\OrderId;
Expand Down Expand Up @@ -39,7 +58,7 @@ class PayPalOrder
*/
private $links;

public function __construct(PayPalOrderId $id = null, $status = null, $intent = null, PayPalOrderPaymentSource $paymentSource = null, $purchaseUnits = [], $payer = [], $createTime = null, $links = [] )
public function __construct(PayPalOrderId $id = null, $status = null, $intent = null, PayPalOrderPaymentSource $paymentSource = null, $purchaseUnits = [], $payer = [], $createTime = null, $links = [])
{
$this->id = $id;
$this->status = $status;
Expand Down Expand Up @@ -189,12 +208,12 @@ public function toArray()
'status' => $this->status,
'intent' => $this->intent,
'payment_source' => $this->paymentSource === null ? null : $this->paymentSource->toArray(),
'purchase_units' => array_map(function(PayPalOrderPurchaseUnit $purchaseUnit) {
'purchase_units' => array_map(function (PayPalOrderPurchaseUnit $purchaseUnit) {
return $purchaseUnit->toArray();
}, $this->purchaseUnits),
'payer' => $this->payer,
'create_time' => $this->createTime,
'links' => $this->links
'links' => $this->links,
];
}
}
19 changes: 19 additions & 0 deletions src/PayPal/Order/ValueObject/PayPalOrderPayer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject;

class PayPalOrderPayer
Expand Down
38 changes: 28 additions & 10 deletions src/PayPal/Order/ValueObject/PayPalOrderPaymentSource.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject;

class PayPalOrderPaymentSource
Expand Down Expand Up @@ -59,7 +78,6 @@ class PayPalOrderPaymentSource
*/
public function __construct($name, $referenceId, $paymentMethodPreference = null, $paymentMethodSelected = null, $brandName = null, $locale = null, $landingPage = null, $userAction = null, $returnUrl = null, $cancelUrl = null)
{

$this->name = $name;
$this->referenceId = $referenceId;
$this->paymentMethodPreference = $paymentMethodPreference;
Expand Down Expand Up @@ -221,16 +239,16 @@ public function toArray()
return [
$this->name => [
'experience_context' => [
"payment_method_preference" => $this->paymentMethodPreference,
"payment_method_selected" => $this->paymentMethodSelected,
"brand_name" => $this->brandName,
"locale" => $this->locale,
"landing_page" => $this->landingPage,
"user_action" => $this->userAction,
"return_url" => $this->returnUrl,
"cancel_url" => $this->cancelUrl,
'payment_method_preference' => $this->paymentMethodPreference,
'payment_method_selected' => $this->paymentMethodSelected,
'brand_name' => $this->brandName,
'locale' => $this->locale,
'landing_page' => $this->landingPage,
'user_action' => $this->userAction,
'return_url' => $this->returnUrl,
'cancel_url' => $this->cancelUrl,
],
]
],
];
}
}
25 changes: 21 additions & 4 deletions src/PayPal/Order/ValueObject/PayPalOrderPurchaseUnit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject;

class PayPalOrderPurchaseUnit
Expand Down Expand Up @@ -100,10 +119,8 @@ public function toArray()
'custom_id' => $this->customId,
'amount' => [
'currency' => $this->currency,
'value' => $this->value
]
'value' => $this->value,
],
];
}


}
12 changes: 6 additions & 6 deletions tests/Unit/Order/Comparator/OrderComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ public function orderProvider()
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CREATE'),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE'),
'intent'
'intent',
],
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'EUR', 100)]),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'USD', 100)]),
'purchase_units'
'purchase_units',
],
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'EUR', 100)]),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'USD', 50)]),
'purchase_units'
'purchase_units',
],
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', new PayPalOrderPaymentSource('paypal', 'PAYPAL')),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'USD', 50)]),
'payment_source'
'payment_source',
],
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', new PayPalOrderPaymentSource('paypal', 'PAYPAL')),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'USD', 50)]),
['payment_source', 'purchase_units']
['payment_source', 'purchase_units'],
],
[
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CREATE', new PayPalOrderPaymentSource('paypal', 'PAYPAL')),
new PayPalOrder(new PayPalOrderId('123'), 'CREATED', 'CAPTURE', null, [new PayPalOrderPurchaseUnit('123', 123, 'USD', 50)]),
['intent', 'payment_source', 'purchase_units']
['intent', 'payment_source', 'purchase_units'],
],
];
}
Expand Down

0 comments on commit 3e6dfdb

Please sign in to comment.