for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sylius\ShopApiPlugin\Factory;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\ShopApiPlugin\View\TotalsView;
final class TotalViewFactory implements TotalViewFactoryInterface
{
/** @var string */
private $totalsViewClass;
public function __construct(string $totalsViewClass)
$this->totalsViewClass = $totalsViewClass;
}
/**
* {@inheritdoc}
*/
public function create(OrderInterface $cart): TotalsView
/** @var TotalsView $totalsView */
$totalsView = new $this->totalsViewClass();
$totalsView->promotion = $cart->getOrderPromotionTotal();
$totalsView->total = $cart->getTotal();
$totalsView->items = $cart->getItemsTotal();
$totalsView->shipping = $cart->getShippingTotal();
$totalsView->taxes = $cart->getTaxTotal();
return $totalsView;