@@ -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 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function xrange(int $start, ?int $size = null, int $step = 1): Range |
| 18 | 18 | { |
| 19 | - if($size === null) { |
|
| 19 | + if ($size === null) { |
|
| 20 | 20 | [$start, $size] = [0, $start]; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $result = new IndexedArray(); |
| 40 | 40 | |
| 41 | - foreach($collection as $item) { |
|
| 41 | + foreach ($collection as $item) { |
|
| 42 | 42 | $result[] = $mapper($item); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $result = new IndexedArray(); |
| 61 | 61 | |
| 62 | - foreach($collection as $item) { |
|
| 63 | - if($filter($item)) { |
|
| 62 | + foreach ($collection as $item) { |
|
| 63 | + if ($filter($item)) { |
|
| 64 | 64 | $result[] = $item; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $carry = $initialValue; |
| 86 | 86 | |
| 87 | - foreach($collection as $item) { |
|
| 87 | + foreach ($collection as $item) { |
|
| 88 | 88 | $carry = $reducer($carry, $item); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -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 | |