Merger::mergeBill()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
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