for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Sylius\ShopApiPlugin\Factory;
use Sylius\Component\Order\Model\AdjustmentInterface;
use Sylius\ShopApiPlugin\View\AdjustmentView;
final class AdjustmentViewFactory implements AdjustmentViewFactoryInterface
{
/** @var PriceViewFactoryInterface */
private $priceViewFactory;
public function __construct(PriceViewFactoryInterface $priceViewFactory)
$this->priceViewFactory = $priceViewFactory;
}
public function create(AdjustmentInterface $adjustment, ?AdjustmentView $additionalAmount): AdjustmentView
$adjustmentView = new AdjustmentView();
$adjustmentView->name = $adjustment->getLabel();
$adjustmentView->amount = $this->priceViewFactory->create(
$additionalAmount ? $adjustment->getAmount() + $additionalAmount->amount->current : $adjustment->getAmount()
);
return $adjustmentView;