StatementBill::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 17
dl 0
loc 38
rs 9.6666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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-2021, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\statement;
12
13
use hiqdev\php\billing\bill\Bill;
14
use hiqdev\php\billing\bill\BillInterface;
15
use hiqdev\php\billing\bill\BillState;
16
use hiqdev\php\billing\type\TypeInterface;
0 ignored issues
show
Bug introduced by
The type hiqdev\php\billing\type\TypeInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use hiqdev\php\billing\customer\CustomerInterface;
18
use hiqdev\php\billing\target\TargetInterface;
19
use hiqdev\php\billing\plan\PlanInterface;
20
use hiqdev\php\units\QuantityInterface;
21
use DateTimeImmutable;
22
use Money\Money;
23
24
/**
25
 * StatementBill.
26
 *
27
 * @author Yurii Myronchuk <[email protected]>
28
 */
29
class StatementBill extends Bill implements StatementBillInterface
30
{
31
    /** @var DateTimeImmutable */
32
    protected $month;
33
34
    /** @var Money */
35
    protected $price;
36
37
    /** @var Money */
38
    protected $overuse;
39
40
    /** @var QuantityInterface */
41
    protected $prepaid;
42
43
    /** @var string */
44
    protected $from;
45
46
    /** @var int */
47
    protected int $unique_objects_count = 0;
48
49
    /** @var TypeInterface */
50
    protected $tariff_type;
51
52
    public function __construct(
53
        $id,
54
        TypeInterface $type,
55
        DateTimeImmutable $time,
56
        Money $sum,
57
        QuantityInterface $quantity,
58
        CustomerInterface $customer,
59
        DateTimeImmutable $month,
60
        int $unique_objects_count,
61
        Money $price = null,
62
        Money $overuse = null,
63
        QuantityInterface $prepaid = null,
64
        array $charges = [],
65
        TargetInterface $target = null,
66
        PlanInterface $plan = null,
67
        BillState $state = null,
68
        ?string $from = null,
69
        TypeInterface $tariff_type = null
70
    ) {
71
        parent::__construct(
72
            $id,
73
            $type,
74
            $time,
75
            $sum,
76
            $quantity,
77
            $customer,
78
            $target,
79
            $plan,
80
            $charges,
81
            $state
82
        );
83
        $this->month                = $month;
84
        $this->unique_objects_count = $unique_objects_count;
85
        $this->price                = $price;
86
        $this->overuse              = $overuse;
87
        $this->prepaid              = $prepaid;
88
        $this->from                 = $from;
89
        $this->tariff_type          = $tariff_type;
90
    }
91
92
    public function getMonth(): DateTimeImmutable
93
    {
94
        return $this->month;
95
    }
96
97
    public function getFrom(): ?string
98
    {
99
        return $this->from;
100
    }
101
102
    public function getPrice(): ?Money
103
    {
104
        return $this->price;
105
    }
106
107
    public function getOveruse(): ?Money
108
    {
109
        return $this->overuse;
110
    }
111
112
    public function getPrepaid(): QuantityInterface
113
    {
114
        return $this->prepaid;
115
    }
116
117
    public function getTariffType(): ?TypeInterface
118
    {
119
        return $this->tariff_type;
120
    }
121
122
    public function getUniqueObjectsCount(): int
123
    {
124
        return $this->unique_objects_count;
125
    }
126
}
127