Total Complexity | 9 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class Partition extends \ArrayObject implements PartitionInterface |
||
15 | { |
||
16 | /** |
||
17 | * @return array |
||
18 | */ |
||
19 | public function exportArrayCopy() |
||
26 | ); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public function getBounds(): array |
||
33 | { |
||
34 | $max = PHP_INT_MAX; |
||
35 | $min = PHP_INT_MIN; |
||
36 | |||
37 | $bounds = []; |
||
38 | |||
39 | foreach ($this as $index => $item) { |
||
40 | if ($item instanceof PartitionItemInterface) { |
||
41 | $item = $item->getWeight(); |
||
42 | } |
||
43 | |||
44 | if ($item < $max) { |
||
45 | $max = $item; |
||
46 | $bounds[0] = $index; |
||
47 | } |
||
48 | |||
49 | if ($item > $min) { |
||
50 | $min = $item; |
||
51 | $bounds[1] = $index; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | return $bounds; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function getWeight(): float |
||
74 | } |
||
75 | } |
||
76 |