Completed
Push — master ( 988510...c327dd )
by Andrii
02:29
created

Billing::perform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\order;
12
13
use hiqdev\php\billing\bill\BillRepositoryInterface;
14
use hiqdev\php\billing\tools\AggregatorInterface;
15
use hiqdev\php\billing\tools\MergerInterface;
16
17
/**
18
 * Billing calculates and saves bills for given order.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class Billing implements BillingInterface
23
{
24
    /**
25
     * @var CalculatorInterface
26
     */
27
    protected $calculator;
28
    /**
29
     * @var AggregatorInterface
30
     */
31
    protected $aggregator;
32
    /**
33
     * @var MergerInterface
34
     */
35
    protected $merger;
36
    /**
37
     * @var BillRepositoryInterface
38
     */
39
    private $billRepository;
40
41
    public function __construct(
42
        CalculatorInterface $calculator,
43
        AggregatorInterface $aggregator,
44
        MergerInterface $merger,
45
        ?BillRepositoryInterface $billRepository
46
    ) {
47
        $this->calculator = $calculator;
48
        $this->aggregator = $aggregator;
49
        $this->merger = $merger;
50
        $this->billRepository = $billRepository;
51
    }
52
53
    public function calculate(OrderInterface $order): array
54
    {
55
        $charges = $this->calculator->calculateOrder($order);
56
        $bills = $this->aggregator->aggregateCharges($charges);
57
58
        return $this->merger->mergeBills($bills);
59
    }
60
61
    public function perform(OrderInterface $order): array
62
    {
63
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return array. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
64
}
65