Total Complexity | 10 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | class Operations |
||
23 | { |
||
24 | /** |
||
25 | * @var Calculator |
||
26 | */ |
||
27 | private $calculator; |
||
28 | |||
29 | /** |
||
30 | * @var integer |
||
31 | */ |
||
32 | private $amountCols = 0; |
||
33 | |||
34 | /** |
||
35 | * @var integer |
||
36 | */ |
||
37 | private $missing = 0; |
||
38 | |||
39 | /** |
||
40 | * @var Column[] |
||
41 | */ |
||
42 | private $columns = array(); |
||
43 | |||
44 | public function __construct(Calculator $calculator) |
||
45 | { |
||
46 | $this->calculator = $calculator; |
||
47 | $this->columns = $calculator->getColumns(); |
||
48 | $this->amountCols = count($this->columns); |
||
49 | |||
50 | foreach($this->columns as $col) |
||
51 | { |
||
52 | if($col->isMissing()) |
||
53 | { |
||
54 | $this->missing++; |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | |||
59 | public function calcTotal() : float |
||
60 | { |
||
61 | $total = 0; |
||
62 | |||
63 | foreach($this->columns as $col) |
||
64 | { |
||
65 | $total += $col->getValue(); |
||
66 | } |
||
67 | |||
68 | return $total; |
||
69 | } |
||
70 | |||
71 | public function countColumns() : int |
||
72 | { |
||
73 | return $this->amountCols; |
||
74 | } |
||
75 | |||
76 | public function countMissing() : int |
||
77 | { |
||
78 | return $this->missing; |
||
79 | } |
||
80 | |||
81 | public function calcTotalNotMissing() : float |
||
94 | } |
||
95 | |||
96 | } |
||
97 |