Completed
Push — 1.7 ( 1627e8...895c05 )
by Kamil
73:45 queued 48:32
created

OrderItemsSubtotalCalculator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSubtotal() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\ShopBundle\Calculator;
6
7
use Sylius\Component\Core\Model\OrderInterface;
8
use Sylius\Component\Core\Model\OrderItemInterface;
9
10
final class OrderItemsSubtotalCalculator implements OrderItemsSubtotalCalculatorInterface
11
{
12
    public function getSubtotal(OrderInterface $order): int
13
    {
14
        return array_reduce(
15
            $order->getItems()->toArray(),
16
            static function (int $subtotal, OrderItemInterface $item): int {
17
                return $subtotal + $item->getSubtotal();
18
            },
19
            0
20
        );
21
    }
22
}
23