Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
23 | 1 | protected function applyDiscount(): void |
|
24 | { |
||
25 | 1 | $subctracts = []; |
|
26 | 1 | $i = 1; |
|
27 | 1 | foreach ($this->items as $item) { |
|
28 | // every even item is free |
||
29 | 1 | if ($i % 2 == 0) { |
|
30 | 1 | $subctracts[] = $item->getPriceTotalWithTax($this->currency); |
|
31 | } |
||
32 | 1 | $i++; |
|
33 | } |
||
34 | |||
35 | 1 | $afterDiscount = call_user_func_array([$this->price, 'subtract'], $subctracts); |
|
36 | |||
37 | 1 | $this->priceAfterDiscount = $afterDiscount; |
|
38 | 1 | } |
|
39 | } |
||
40 |