@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function offsetSet($offset, $value): void |
| 67 | 67 | { |
| 68 | - if($offset === null) { |
|
| 68 | + if ($offset === null) { |
|
| 69 | 69 | $this->source[] = $value; |
| 70 | 70 | } else { |
| 71 | 71 | $range = $this->getRange(); |
| 72 | - if(isset($range[$offset])) { |
|
| 72 | + if (isset($range[$offset])) { |
|
| 73 | 73 | $index = $range[$offset]; |
| 74 | 74 | $this->source[$index] = $value; |
| 75 | 75 | } else { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function offsetUnset($offset): void |
| 85 | 85 | { |
| 86 | 86 | $range = $this->getRange(); |
| 87 | - if(isset($range[$offset])) { |
|
| 87 | + if (isset($range[$offset])) { |
|
| 88 | 88 | $index = $range[$offset]; |
| 89 | 89 | unset($this->source[$index]); |
| 90 | 90 | $this->source = array_values($this->source); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function getValueByIndex(int $index) |
| 17 | 17 | { |
| 18 | - return $this->start + $index * $this->step; |
|
| 18 | + return $this->start+$index*$this->step; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -24,6 +24,6 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function getNextValue($previousValue) |
| 26 | 26 | { |
| 27 | - return $previousValue + $this->step; |
|
| 27 | + return $previousValue+$this->step; |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function offsetExists($offset): bool |
| 40 | 40 | { |
| 41 | - if(!is_int($offset)) { |
|
| 41 | + if (!is_int($offset)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(!$this->isInfinite()) { |
|
| 46 | - if($offset >= 0) { |
|
| 45 | + if (!$this->isInfinite()) { |
|
| 46 | + if ($offset >= 0) { |
|
| 47 | 47 | return $offset < count($this); |
| 48 | 48 | } |
| 49 | 49 | return abs($offset) <= count($this); |
@@ -99,21 +99,21 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function offsetGet($offset) |
| 101 | 101 | { |
| 102 | - if(!$this->offsetExists($offset)) { |
|
| 102 | + if (!$this->offsetExists($offset)) { |
|
| 103 | 103 | throw new OutOfRangeException(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** @var int $offset */ |
| 107 | 107 | |
| 108 | - if($this->isInfinite()) { |
|
| 108 | + if ($this->isInfinite()) { |
|
| 109 | 109 | return $this->getValueByIndex($offset); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($offset < 0) { |
|
| 113 | - $offset = $this->size + ($offset % $this->size); |
|
| 112 | + if ($offset < 0) { |
|
| 113 | + $offset = $this->size+($offset%$this->size); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $offset = ($offset % $this->size); |
|
| 116 | + $offset = ($offset%$this->size); |
|
| 117 | 117 | |
| 118 | 118 | return $this->getValueByIndex($offset); |
| 119 | 119 | } |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function getValueByIndex(int $index) |
| 28 | 28 | { |
| 29 | - if ((float)$this->step === 0.0 && $index < 0) { |
|
| 29 | + if ((float) $this->step === 0.0 && $index < 0) { |
|
| 30 | 30 | throw new \DivisionByZeroError(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return $this->start * ($this->step ** $index); |
|
| 33 | + return $this->start*($this->step ** $index); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -39,6 +39,6 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getNextValue($previousValue) |
| 41 | 41 | { |
| 42 | - return $previousValue * $this->step; |
|
| 42 | + return $previousValue*$this->step; |
|
| 43 | 43 | } |
| 44 | 44 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function getValueByIndex(int $index) |
| 56 | 56 | { |
| 57 | - if(is_callable($this->indexValueGetter)) { |
|
| 57 | + if (is_callable($this->indexValueGetter)) { |
|
| 58 | 58 | return ($this->indexValueGetter)($index, $this->start); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function xrange(int $start, ?int $size = null, int $step = 1): Range |
| 21 | 21 | { |
| 22 | - if($size === null) { |
|
| 22 | + if ($size === null) { |
|
| 23 | 23 | [$start, $size] = [0, $start]; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -41,21 +41,21 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $result = new IndexedArray(); |
| 43 | 43 | |
| 44 | - if(count($collections) === 0) { |
|
| 44 | + if (count($collections) === 0) { |
|
| 45 | 45 | return $result; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $it = new MultipleIterator(MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 48 | + $it = new MultipleIterator(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 49 | 49 | |
| 50 | - foreach($collections as $collection) { |
|
| 51 | - if(is_array($collection)) { |
|
| 50 | + foreach ($collections as $collection) { |
|
| 51 | + if (is_array($collection)) { |
|
| 52 | 52 | $collection = new ArrayIterator($collection); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $it->attachIterator(new IteratorIterator($collection)); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - foreach($it as $values) { |
|
| 58 | + foreach ($it as $values) { |
|
| 59 | 59 | $result[] = $mapper(...$values); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $result = new IndexedArray(); |
| 78 | 78 | |
| 79 | - foreach($collection as $item) { |
|
| 80 | - if($filter($item)) { |
|
| 79 | + foreach ($collection as $item) { |
|
| 80 | + if ($filter($item)) { |
|
| 81 | 81 | $result[] = $item; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $carry = $initialValue; |
| 103 | 103 | |
| 104 | - foreach($collection as $item) { |
|
| 104 | + foreach ($collection as $item) { |
|
| 105 | 105 | $carry = $reducer($carry, $item); |
| 106 | 106 | } |
| 107 | 107 | |