Total Complexity | 6 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class SimpleCalculator extends Calculator |
||
22 | { |
||
23 | /** |
||
24 | * @param GeneralizerInterface $generalizer |
||
25 | * @param SaleRepositoryInterface|SaleInterface $sale |
||
26 | * @param PlanRepositoryInterface|PlanInterface $plan |
||
27 | */ |
||
28 | public function __construct(GeneralizerInterface $generalizer = null, $sale = null, $plan = null) |
||
29 | { |
||
30 | $this->generalizer = $generalizer ?: new Generalizer(); |
||
31 | if ($sale instanceof SaleInterface) { |
||
32 | if (empty($plan)) { |
||
33 | $plan = $sale->getPlan(); |
||
34 | } |
||
35 | $sale = new SimpleSaleRepository($sale); |
||
36 | } |
||
37 | if ($plan instanceof PlanInterface) { |
||
38 | $plan = new SimplePlanRepository($plan); |
||
39 | } |
||
40 | |||
41 | return parent::__construct($this->generalizer, $sale, $plan); |
||
42 | } |
||
43 | |||
44 | public function getGeneralizer(): GeneralizerInterface |
||
45 | { |
||
46 | return $this->generalizer; |
||
47 | } |
||
49 |