Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function __construct(array $items) |
||
16 | { |
||
17 | if(count($items) < 2) |
||
18 | { |
||
19 | throw new \RuntimeException('Pairs must be initialized with at least two items'); |
||
20 | } |
||
21 | $this->hasNext = true; |
||
22 | $this->firstIndex = 0; |
||
23 | $this->secondIndex = 1; |
||
24 | $this->maxIndex = count($items); |
||
25 | |||
26 | $this->keys = array(); |
||
27 | $this->values = array(); |
||
28 | foreach($items as $key => $value) |
||
29 | { |
||
30 | $this->keys[] = $key; |
||
31 | $this->values[] = $value; |
||
32 | } |
||
33 | } |
||
34 | |||
74 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.