NumbersCollection::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hotrush\AngularSweep;
4
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()
45
    {
46
        return count($this->numbers);
47
    }
48
}