Skip to content

Commit

Permalink
post review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jocel1 committed Jun 1, 2018
1 parent b403e58 commit 021a53d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
},
"author": "PrestaShop",
"license": "OSL-3.0"
}
}
6 changes: 4 additions & 2 deletions src/Adapter/Presenter/Module/ModulePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
namespace PrestaShop\PrestaShop\Adapter\Presenter\Module;

use Currency;
use PrestaShop\PrestaShop\Adapter\Module\Module;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface;
use Exception;

class ModulePresenter implements PresenterInterface
{
Expand All @@ -52,8 +54,8 @@ public function __construct(Currency $currency, PriceFormatter $priceFormatter)
*/
public function present($module)
{
if (!is_a($module, '\\PrestaShop\\PrestaShop\\Adapter\\Module\\Module')) {
throw new \Exception("ModulePresenter can only present instance of Module");
if (!($module instanceof Module)) {
throw new Exception("ModulePresenter can only present instance of Module");
}

$attributes = $module->attributes->all();
Expand Down
15 changes: 7 additions & 8 deletions src/Adapter/Presenter/Object/ObjectPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@

use Hook;
use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface;
use ObjectModel;
use Exception;

class ObjectPresenter implements PresenterInterface
{
/**
* @param \ObjectModel $object
* @param ObjectModel $object
*
* @return array
* @throws \Exception
* @throws Exception
*/
public function present($object)
{
if (!is_a($object, 'ObjectModel')) {
throw new \Exception('ObjectPresenter can only present ObjectModel classes');
if (!($object instanceof ObjectModel)) {
throw new Exception('ObjectPresenter can only present ObjectModel classes');
}

$presentedObject = array();
Expand All @@ -49,10 +51,7 @@ public function present($object)
foreach ($fields as $fieldName => $null) {
$presentedObject[$fieldName] = $object->{$fieldName};
}
$mustHave = ['id'];
foreach ($mustHave as $fieldName) {
$presentedObject[$fieldName] = $object->{$fieldName};
}
$presentedObject['id'] = $object->id;

$mustRemove = ['deleted', 'active'];
foreach ($mustRemove as $fieldName) {
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Presenter/Order/OrderDetailLazyArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OrderDetailLazyArray extends AbstractLazyArray
/**
* OrderDetailLazyArray constructor.
*/
public function __construct($order)
public function __construct(Order $order)
{
$this->order = $order;
$this->context = Context::getContext();
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Presenter/Order/OrderLazyArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class OrderLazyArray extends AbstractLazyArray
* @throws AnnotationException
* @throws ReflectionException
*/
public function __construct($order)
public function __construct(Order $order)
{
$this->order = $order;
$this->cartPresenter = new CartPresenter();
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Presenter/Order/OrderPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class OrderPresenter implements PresenterInterface
*/
public function present($order)
{
if (!is_a($order, 'Order')) {
throw new Exception('OrderArray can only present instance of Order');
if (!($order instanceof Order)) {
throw new Exception('OrderPresenter can only present instance of Order');
}

return new OrderLazyArray($order);
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class OrderSubtotalLazyArray extends AbstractLazyArray
/**
* OrderSubtotalLazyArray constructor.
*/
public function __construct($order)
public function __construct(Order $order)
{
$this->context = Context::getContext();
$this->taxConfiguration = new TaxConfiguration();
Expand Down Expand Up @@ -99,7 +99,7 @@ public function getDiscounts()
$discountAmount = ($this->includeTaxes)
? $this->order->total_discounts_tax_incl
: $this->order->total_discounts_tax_excl;
if ((float) $discountAmount) {
if ($discountAmount) {
return array(
'type' => 'discount',
'label' => $this->translator->trans('Discount', array(), 'Shop.Theme.Checkout'),
Expand Down Expand Up @@ -156,7 +156,7 @@ public function getShipping()
public function getTax()
{
$tax = $this->order->total_paid_tax_incl - $this->order->total_paid_tax_excl;
if ((float) $tax && Configuration::get('PS_TAX_DISPLAY')) {
if ($tax && Configuration::get('PS_TAX_DISPLAY')) {
return array(
'type' => 'tax',
'label' => $this->translator->trans('Tax', array(), 'Shop.Theme.Checkout'),
Expand Down

0 comments on commit 021a53d

Please sign in to comment.