|
123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Order;
-
- use Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface;
-
- class OrderProductReductionCatalogSolver
- {
- // getSummaryOrderProductReductionCatalog
- public function getSummary(OrderProductReductionCatalogInterface $orderProductReductionCatalog): string
- {
- $text = '';
-
- if ($orderProductReductionCatalog->getUnit() == 'amount') {
- $text .= '- ' . number_format($orderProductReductionCatalog->getValue(),2) . ' €';
- }
-
- if ($orderProductReductionCatalog->getUnit() == 'percent') {
- $text .= '- ' . number_format($orderProductReductionCatalog->getValue(),2) . ' %';
- }
-
- return $text;
- }
-
- // compareOrderProductReductionCatalog
- public function compare(
- OrderProductReductionCatalogInterface $orderProductReductionCatalog = null,
- OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare = null
- ): bool {
-
- if(is_null($orderProductReductionCatalog) && is_null($orderProductReductionCatalogCompare)) {
- return true;
- }
-
- if(is_null($orderProductReductionCatalog) || is_null($orderProductReductionCatalogCompare)) {
- return false;
- }
-
- return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit()
- && (string)$orderProductReductionCatalog->getValue(
- ) == (string)$orderProductReductionCatalogCompare->getValue()
- && $orderProductReductionCatalog->getBehaviorTaxRate(
- ) == $orderProductReductionCatalogCompare->getBehaviorTaxRate();
- }
- }
|