Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class NumbersCollection |
||
6 | { |
||
7 | /** |
||
8 | * @var ComplexNumber[] |
||
9 | */ |
||
10 | private $numbers = []; |
||
11 | |||
12 | /** |
||
13 | * @param ComplexNumber $number |
||
14 | */ |
||
15 | public function add(ComplexNumber $number) |
||
16 | { |
||
17 | $this->numbers[] = $number; |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @return ComplexNumber[] |
||
22 | */ |
||
23 | public function all() |
||
24 | { |
||
25 | return $this->numbers; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param $key |
||
30 | * @return ComplexNumber |
||
31 | */ |
||
32 | public function get($key) |
||
33 | { |
||
34 | if (!isset($this->numbers[$key])) { |
||
35 | throw new \InvalidArgumentException('Number with this key doesn\'t exist'); |
||
36 | } |
||
37 | |||
38 | return $this->numbers[$key]; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return int |
||
43 | */ |
||
44 | public function total() |
||
47 | } |
||
48 | } |