Total Complexity | 11 |
Total Lines | 113 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class PrimeFactors extends Iterators |
||
12 | { |
||
13 | /** |
||
14 | * The prime factors. |
||
15 | * |
||
16 | * @var int[] |
||
17 | */ |
||
18 | protected $factors; |
||
19 | |||
20 | /** |
||
21 | * The number. |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $number; |
||
26 | |||
27 | /** |
||
28 | * Count elements of an object. |
||
29 | * |
||
30 | * @return int |
||
31 | * The number of element |
||
32 | */ |
||
33 | 3 | public function count(): int |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 3 | public function current(): mixed |
|
42 | { |
||
43 | 3 | return current($this->factors); |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get the number. |
||
48 | * |
||
49 | * @return int |
||
50 | * The number |
||
51 | */ |
||
52 | 3 | public function getNumber(): int |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | 3 | public function next(): void |
|
63 | { |
||
64 | 3 | ++$this->key; |
|
65 | 3 | next($this->factors); |
|
66 | 3 | } |
|
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | 3 | public function rewind(): void |
|
74 | 3 | } |
|
75 | |||
76 | /** |
||
77 | * Set the number. |
||
78 | * |
||
79 | * @param int $number |
||
80 | * The number |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | 3 | public function setNumber($number): void |
|
88 | 3 | } |
|
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | 3 | public function valid(): bool |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Compute the prime factors of the number. |
||
102 | * |
||
103 | * @param mixed $number |
||
104 | * |
||
105 | * @return int[] |
||
106 | * The factors |
||
107 | */ |
||
108 | 3 | private function getFactors($number): array |
|
126 |