| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4.0072 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 7 | public function commit(ItemHolderInterface $target, PurchaseContext $context) |
|
| 26 | { |
||
| 27 | 7 | if (!$target instanceof Order) { |
|
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | 7 | $Customer = $target->getCustomer(); |
|
| 32 | 7 | if (!$Customer) { |
|
| 33 | 3 | return; |
|
| 34 | } |
||
| 35 | |||
| 36 | 4 | $now = new \DateTime(); |
|
| 37 | 4 | $firstBuyDate = $Customer->getFirstBuyDate(); |
|
| 38 | 4 | if (empty($firstBuyDate)) { |
|
| 39 | 4 | $Customer->setFirstBuyDate($now); |
|
| 40 | } |
||
| 41 | 4 | $Customer->setLastBuyDate($now); |
|
| 42 | |||
| 43 | 4 | $Customer->setBuyTimes($Customer->getBuyTimes() + 1); |
|
| 44 | 4 | $Customer->setBuyTotal($Customer->getBuyTotal() + $target->getTotal()); |
|
| 45 | } |
||
| 46 | } |
||
| 47 |