Merger   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 10
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeBill() 0 3 1
A mergeBills() 0 9 2
A __construct() 0 4 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\tools;
4
5
use hiqdev\php\billing\bill\BillInterface;
6
use hiqdev\php\billing\tools\MergerInterface;
7
8
/**
9
 * @author Dmytro Naumenko <[email protected]>
10
 */
11
class Merger implements MergerInterface
12
{
13
    /**
14
     * @var MonthlyBillQuantityFixer
15
     */
16
    private $monthlyBillQuantityFixer;
17
    /**
18
     * @var MergerInterface
19
     */
20
    private $defaultMerger;
21
22
    public function __construct(MergerInterface $defaultMerger, MonthlyBillQuantityFixer $monthlyBillQuantityFixer)
23
    {
24
        $this->defaultMerger = $defaultMerger;
25
        $this->monthlyBillQuantityFixer = $monthlyBillQuantityFixer;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function mergeBills(array $bills): array
32
    {
33
        $bills = $this->defaultMerger->mergeBills($bills);
34
35
        foreach ($bills as $bill) {
36
            $this->monthlyBillQuantityFixer->__invoke($bill);
37
        }
38
39
        return $bills;
40
    }
41
42
    public function mergeBill(BillInterface $first, BillInterface $other): BillInterface
43
    {
44
        return $this->defaultMerger->mergeBill($first, $other);
45
    }
46
}
47