<?php
/**
* Fixed Discount
*
* (c) Bertin van den Ham <b.vandenham@dappr.nl>
*/
namespace VisualMedia\DiscountBundle\Discount\Factory;
use VisualMedia\DiscountBundle\Discount\DiscountFactory;
use VisualMedia\DiscountBundle\Discount\DiscountFactoryInterface;
use VisualMedia\OrderBundle\Service\Cart;
/**
* Fixed Discount
*
* Fixed Discount on the order
* @example €5,- off the order total
*/
class FixedDiscount extends DiscountFactory implements DiscountFactoryInterface
{
public const NAME = 'fixed_discount';
/**
* {@inheritDoc}
*/
public static function getName(): string
{
return static::NAME;
}
/**
* {@inheritDoc}
*/
public function getDiscount(Cart $cart = null): float
{
if (null === $order = $cart->getOrder()) {
return 0;
}
if (null === $discount = $order->getDiscount()) {
return 0;
}
return (float) $discount->getValue();
}
}