@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | * @return Enumerable Endless list of items repeating the source sequence. |
| 17 | 17 | * @package YaLinqo\Generation |
| 18 | 18 | */ |
| 19 | - public static function cycle ($source) |
|
| 19 | + public static function cycle($source) |
|
| 20 | 20 | { |
| 21 | 21 | $source = self::from($source); |
| 22 | 22 | |
| 23 | - return new self(function () use ($source) { |
|
| 23 | + return new self(function() use ($source) { |
|
| 24 | 24 | $isEmpty = true; |
| 25 | 25 | while (true) { |
| 26 | 26 | foreach ($source as $v) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return Enumerable |
| 40 | 40 | * @package YaLinqo\Generation |
| 41 | 41 | */ |
| 42 | - public static function emptyEnum () |
|
| 42 | + public static function emptyEnum() |
|
| 43 | 43 | { |
| 44 | 44 | return new self(new \EmptyIterator, false); |
| 45 | 45 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @return Enumerable |
| 60 | 60 | * @package YaLinqo\Generation |
| 61 | 61 | */ |
| 62 | - public static function from ($source) |
|
| 62 | + public static function from($source) |
|
| 63 | 63 | { |
| 64 | 64 | $it = null; |
| 65 | 65 | if ($source instanceof Enumerable) |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * @return Enumerable |
| 88 | 88 | * @package YaLinqo\Generation |
| 89 | 89 | */ |
| 90 | - public static function generate ($funcValue, $seedValue = null, $funcKey = null, $seedKey = null) |
|
| 90 | + public static function generate($funcValue, $seedValue = null, $funcKey = null, $seedKey = null) |
|
| 91 | 91 | { |
| 92 | 92 | $funcValue = Utils::createLambda($funcValue, 'v,k'); |
| 93 | 93 | $funcKey = Utils::createLambda($funcKey, 'v,k', false); |
| 94 | 94 | |
| 95 | - return new self(function () use ($funcValue, $funcKey, $seedValue, $seedKey) { |
|
| 95 | + return new self(function() use ($funcValue, $funcKey, $seedValue, $seedKey) { |
|
| 96 | 96 | $key = $seedKey === null ? ($funcKey ? $funcKey($seedValue, $seedKey) : 0) : $seedKey; |
| 97 | 97 | $value = $seedValue === null ? $funcValue($seedValue, $seedKey) : $seedValue; |
| 98 | 98 | yield $key => $value; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @return Enumerable |
| 115 | 115 | * @package YaLinqo\Generation |
| 116 | 116 | */ |
| 117 | - public static function toInfinity ($start = 0, $step = 1) |
|
| 117 | + public static function toInfinity($start = 0, $step = 1) |
|
| 118 | 118 | { |
| 119 | - return new self(function () use ($start, $step) { |
|
| 119 | + return new self(function() use ($start, $step) { |
|
| 120 | 120 | $value = $start - $step; |
| 121 | 121 | while (true) |
| 122 | 122 | yield $value += $step; |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * @see preg_match_all |
| 134 | 134 | * @package YaLinqo\Generation |
| 135 | 135 | */ |
| 136 | - public static function matches ($subject, $pattern, $flags = PREG_SET_ORDER) |
|
| 136 | + public static function matches($subject, $pattern, $flags = PREG_SET_ORDER) |
|
| 137 | 137 | { |
| 138 | - return new self(function () use ($subject, $pattern, $flags) { |
|
| 138 | + return new self(function() use ($subject, $pattern, $flags) { |
|
| 139 | 139 | preg_match_all($pattern, $subject, $matches, $flags); |
| 140 | 140 | return $matches !== false ? self::from($matches)->getIterator() : self::emptyEnum(); |
| 141 | 141 | }); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return Enumerable |
| 150 | 150 | * @package YaLinqo\Generation |
| 151 | 151 | */ |
| 152 | - public static function toNegativeInfinity ($start = 0, $step = 1) |
|
| 152 | + public static function toNegativeInfinity($start = 0, $step = 1) |
|
| 153 | 153 | { |
| 154 | 154 | return self::toInfinity($start, -$step); |
| 155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @return Enumerable Observable sequence containing the single specified element. |
| 162 | 162 | * @package YaLinqo\Generation |
| 163 | 163 | */ |
| 164 | - public static function returnEnum ($element) |
|
| 164 | + public static function returnEnum($element) |
|
| 165 | 165 | { |
| 166 | 166 | return self::repeat($element, 1); |
| 167 | 167 | } |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | * @return Enumerable A sequence that contains a range of integral numbers. |
| 178 | 178 | * @package YaLinqo\Generation |
| 179 | 179 | */ |
| 180 | - public static function range ($start, $count, $step = 1) |
|
| 180 | + public static function range($start, $count, $step = 1) |
|
| 181 | 181 | { |
| 182 | 182 | if ($count <= 0) |
| 183 | 183 | return self::emptyEnum(); |
| 184 | - return new self(function () use ($start, $count, $step) { |
|
| 184 | + return new self(function() use ($start, $count, $step) { |
|
| 185 | 185 | $value = $start - $step; |
| 186 | 186 | while ($count-- > 0) |
| 187 | 187 | yield $value += $step; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @return Enumerable A sequence that contains a range of integral numbers. |
| 200 | 200 | * @package YaLinqo\Generation |
| 201 | 201 | */ |
| 202 | - public static function rangeDown ($start, $count, $step = 1) |
|
| 202 | + public static function rangeDown($start, $count, $step = 1) |
|
| 203 | 203 | { |
| 204 | 204 | return self::range($start, $count, -$step); |
| 205 | 205 | } |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | * @return Enumerable A sequence that contains a range of integral numbers. |
| 217 | 217 | * @package YaLinqo\Generation |
| 218 | 218 | */ |
| 219 | - public static function rangeTo ($start, $end, $step = 1) |
|
| 219 | + public static function rangeTo($start, $end, $step = 1) |
|
| 220 | 220 | { |
| 221 | 221 | if ($step <= 0) |
| 222 | 222 | throw new \InvalidArgumentException(Errors::STEP_NEGATIVE); |
| 223 | - return new self(function () use ($start, $end, $step) { |
|
| 223 | + return new self(function() use ($start, $end, $step) { |
|
| 224 | 224 | if ($start <= $end) { |
| 225 | 225 | for ($i = $start; $i < $end; $i += $step) |
| 226 | 226 | yield $i; |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | * @return Enumerable A sequence that contains a repeated value. |
| 246 | 246 | * @package YaLinqo\Generation |
| 247 | 247 | */ |
| 248 | - public static function repeat ($element, $count = null) |
|
| 248 | + public static function repeat($element, $count = null) |
|
| 249 | 249 | { |
| 250 | 250 | if ($count < 0) |
| 251 | 251 | throw new \InvalidArgumentException(Errors::COUNT_LESS_THAN_ZERO); |
| 252 | - return new self(function () use ($element, $count) { |
|
| 252 | + return new self(function() use ($element, $count) { |
|
| 253 | 253 | for ($i = 0; $i < $count || $count === null; $i++) |
| 254 | 254 | yield $element; |
| 255 | 255 | }); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @see preg_split |
| 266 | 266 | * @package YaLinqo\Generation |
| 267 | 267 | */ |
| 268 | - public static function split ($subject, $pattern, $flags = 0) |
|
| 268 | + public static function split($subject, $pattern, $flags = 0) |
|
| 269 | 269 | { |
| 270 | 270 | return new self( |
| 271 | 271 | new \ArrayIterator(preg_split($pattern, $subject, -1, $flags)), |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @return mixed The value at the key in the source sequence. |
| 18 | 18 | * @package YaLinqo\Pagination |
| 19 | 19 | */ |
| 20 | - public function elementAt ($key) |
|
| 20 | + public function elementAt($key) |
|
| 21 | 21 | { |
| 22 | 22 | /** @var $it \Iterator|\ArrayAccess */ |
| 23 | 23 | $it = $this->getIterator(); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @return mixed default value if the key is not found in the source sequence; otherwise, the value at the specified key in the source sequence. |
| 45 | 45 | * @package YaLinqo\Pagination |
| 46 | 46 | */ |
| 47 | - public function elementAtOrDefault ($key, $default = null) |
|
| 47 | + public function elementAtOrDefault($key, $default = null) |
|
| 48 | 48 | { |
| 49 | 49 | /** @var $it \Iterator|\ArrayAccess */ |
| 50 | 50 | $it = $this->getIterator(); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @return mixed If predicate is null: the first element in the specified sequence. If predicate is not null: The first element in the sequence that passes the test in the specified predicate function. |
| 73 | 73 | * @package YaLinqo\Pagination |
| 74 | 74 | */ |
| 75 | - public function first ($predicate = null) |
|
| 75 | + public function first($predicate = null) |
|
| 76 | 76 | { |
| 77 | 77 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 78 | 78 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return mixed If predicate is null: default value if source is empty; otherwise, the first element in source. If predicate is not null: default value if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate. |
| 96 | 96 | * @package YaLinqo\Pagination |
| 97 | 97 | */ |
| 98 | - public function firstOrDefault ($default = null, $predicate = null) |
|
| 98 | + public function firstOrDefault($default = null, $predicate = null) |
|
| 99 | 99 | { |
| 100 | 100 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 101 | 101 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return mixed If predicate is null: the result of calling a fallback function if source is empty; otherwise, the first element in source. If predicate is not null: the result of calling a fallback function if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate. |
| 119 | 119 | * @package YaLinqo\Pagination |
| 120 | 120 | */ |
| 121 | - public function firstOrFallback ($fallback, $predicate = null) |
|
| 121 | + public function firstOrFallback($fallback, $predicate = null) |
|
| 122 | 122 | { |
| 123 | 123 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 124 | 124 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @return mixed If predicate is null: the last element in the specified sequence. If predicate is not null: The last element in the sequence that passes the test in the specified predicate function. |
| 143 | 143 | * @package YaLinqo\Pagination |
| 144 | 144 | */ |
| 145 | - public function last ($predicate = null) |
|
| 145 | + public function last($predicate = null) |
|
| 146 | 146 | { |
| 147 | 147 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 148 | 148 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @return mixed If predicate is null: default value if source is empty; otherwise, the last element in source. If predicate is not null: default value if source is empty or if no element passes the test specified by predicate; otherwise, the last element in source that passes the test specified by predicate. |
| 172 | 172 | * @package YaLinqo\Pagination |
| 173 | 173 | */ |
| 174 | - public function lastOrDefault ($default = null, $predicate = null) |
|
| 174 | + public function lastOrDefault($default = null, $predicate = null) |
|
| 175 | 175 | { |
| 176 | 176 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 177 | 177 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return mixed If predicate is null: the result of calling a fallback function if source is empty; otherwise, the last element in source. If predicate is not null: the result of calling a fallback function if source is empty or if no element passes the test specified by predicate; otherwise, the last element in source that passes the test specified by predicate. |
| 199 | 199 | * @package YaLinqo\Pagination |
| 200 | 200 | */ |
| 201 | - public function lastOrFallback ($fallback, $predicate = null) |
|
| 201 | + public function lastOrFallback($fallback, $predicate = null) |
|
| 202 | 202 | { |
| 203 | 203 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 204 | 204 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @return mixed If predicate is null: the single element of the input sequence. If predicate is not null: The single element of the sequence that passes the test in the specified predicate function. |
| 227 | 227 | * @package YaLinqo\Pagination |
| 228 | 228 | */ |
| 229 | - public function single ($predicate = null) |
|
| 229 | + public function single($predicate = null) |
|
| 230 | 230 | { |
| 231 | 231 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 232 | 232 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @return mixed If predicate is null: default value if source is empty; otherwise, the single element of the source. If predicate is not null: default value if source is empty or if no element passes the test specified by predicate; otherwise, the single element of the source that passes the test specified by predicate. |
| 259 | 259 | * @package YaLinqo\Pagination |
| 260 | 260 | */ |
| 261 | - public function singleOrDefault ($default = null, $predicate = null) |
|
| 261 | + public function singleOrDefault($default = null, $predicate = null) |
|
| 262 | 262 | { |
| 263 | 263 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 264 | 264 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @return mixed If predicate is null: the result of calling a fallback function if source is empty; otherwise, the single element of the source. If predicate is not null: the result of calling a fallback function if source is empty or if no element passes the test specified by predicate; otherwise, the single element of the source that passes the test specified by predicate. |
| 289 | 289 | * @package YaLinqo\Pagination |
| 290 | 290 | */ |
| 291 | - public function singleOrFallback ($fallback, $predicate = null) |
|
| 291 | + public function singleOrFallback($fallback, $predicate = null) |
|
| 292 | 292 | { |
| 293 | 293 | $predicate = Utils::createLambda($predicate, 'v,k', Functions::$true); |
| 294 | 294 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @return mixed The key of the first occurrence of value, if found; otherwise, null. |
| 314 | 314 | * @package YaLinqo\Pagination |
| 315 | 315 | */ |
| 316 | - public function indexOf ($value) |
|
| 316 | + public function indexOf($value) |
|
| 317 | 317 | { |
| 318 | 318 | foreach ($this as $k => $v) { |
| 319 | 319 | if ($v === $value) |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @return mixed The key of the last occurrence of value, if found; otherwise, null. |
| 331 | 331 | * @package YaLinqo\Pagination |
| 332 | 332 | */ |
| 333 | - public function lastIndexOf ($value) |
|
| 333 | + public function lastIndexOf($value) |
|
| 334 | 334 | { |
| 335 | 335 | $key = null; |
| 336 | 336 | foreach ($this as $k => $v) { |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * @return mixed The key of the first occurrence of an element that matches the conditions defined by predicate, if found; otherwise, null. |
| 349 | 349 | * @package YaLinqo\Pagination |
| 350 | 350 | */ |
| 351 | - public function findIndex ($predicate) |
|
| 351 | + public function findIndex($predicate) |
|
| 352 | 352 | { |
| 353 | 353 | $predicate = Utils::createLambda($predicate, 'v,k'); |
| 354 | 354 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @return mixed The key of the last occurrence of an element that matches the conditions defined by predicate, if found; otherwise, null. |
| 368 | 368 | * @package YaLinqo\Pagination |
| 369 | 369 | */ |
| 370 | - public function findLastIndex ($predicate) |
|
| 370 | + public function findLastIndex($predicate) |
|
| 371 | 371 | { |
| 372 | 372 | $predicate = Utils::createLambda($predicate, 'v,k'); |
| 373 | 373 | |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | * @return Enumerable A sequence that contains the elements that occur after the specified index in the input sequence. |
| 389 | 389 | * @package YaLinqo\Pagination |
| 390 | 390 | */ |
| 391 | - public function skip ($count) |
|
| 391 | + public function skip($count) |
|
| 392 | 392 | { |
| 393 | - return new self(function () use ($count) { |
|
| 393 | + return new self(function() use ($count) { |
|
| 394 | 394 | $it = $this->getIterator(); |
| 395 | 395 | $it->rewind(); |
| 396 | 396 | for ($i = 0; $i < $count && $it->valid(); ++$i) |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | * @return Enumerable A sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. |
| 412 | 412 | * @package YaLinqo\Pagination |
| 413 | 413 | */ |
| 414 | - public function skipWhile ($predicate) |
|
| 414 | + public function skipWhile($predicate) |
|
| 415 | 415 | { |
| 416 | 416 | $predicate = Utils::createLambda($predicate, 'v,k'); |
| 417 | 417 | |
| 418 | - return new self(function () use ($predicate) { |
|
| 418 | + return new self(function() use ($predicate) { |
|
| 419 | 419 | $yielding = false; |
| 420 | 420 | foreach ($this as $k => $v) { |
| 421 | 421 | if (!$yielding && !$predicate($v, $k)) |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | * @return Enumerable A sequence that contains the specified number of elements from the start of the input sequence. |
| 436 | 436 | * @package YaLinqo\Pagination |
| 437 | 437 | */ |
| 438 | - public function take ($count) |
|
| 438 | + public function take($count) |
|
| 439 | 439 | { |
| 440 | 440 | if ($count <= 0) |
| 441 | 441 | return new self(new \EmptyIterator, false); |
| 442 | 442 | |
| 443 | - return new self(function () use ($count) { |
|
| 443 | + return new self(function() use ($count) { |
|
| 444 | 444 | foreach ($this as $k => $v) { |
| 445 | 445 | yield $k => $v; |
| 446 | 446 | if (--$count == 0) |
@@ -458,11 +458,11 @@ discard block |
||
| 458 | 458 | * @return Enumerable A sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. |
| 459 | 459 | * @package YaLinqo\Pagination |
| 460 | 460 | */ |
| 461 | - public function takeWhile ($predicate) |
|
| 461 | + public function takeWhile($predicate) |
|
| 462 | 462 | { |
| 463 | 463 | $predicate = Utils::createLambda($predicate, 'v,k'); |
| 464 | 464 | |
| 465 | - return new self(function () use ($predicate) { |
|
| 465 | + return new self(function() use ($predicate) { |
|
| 466 | 466 | foreach ($this as $k => $v) { |
| 467 | 467 | if (!$predicate($v, $k)) |
| 468 | 468 | break; |
@@ -474,5 +474,5 @@ discard block |
||
| 474 | 474 | /** |
| 475 | 475 | * @return \Iterator |
| 476 | 476 | */ |
| 477 | - public abstract function getIterator (); |
|
| 477 | + public abstract function getIterator(); |
|
| 478 | 478 | } |
| 479 | 479 | \ No newline at end of file |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | * @codeCoverageIgnore |
| 39 | 39 | * @internal |
| 40 | 40 | */ |
| 41 | - public static function init () |
|
| 41 | + public static function init() |
|
| 42 | 42 | { |
| 43 | 43 | self::$lambdaCache = [ |
| 44 | - '$v' => [ 'v,k' => Functions::$value ], |
|
| 45 | - '$k' => [ 'v,k' => Functions::$key ], |
|
| 44 | + '$v' => ['v,k' => Functions::$value], |
|
| 45 | + '$k' => ['v,k' => Functions::$key], |
|
| 46 | 46 | ]; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @throws \InvalidArgumentException Incorrect lambda syntax. |
| 56 | 56 | * @return callable|null |
| 57 | 57 | */ |
| 58 | - public static function createLambda ($closure, $closureArgs, $default = null) |
|
| 58 | + public static function createLambda($closure, $closureArgs, $default = null) |
|
| 59 | 59 | { |
| 60 | 60 | if ($closure === null) { |
| 61 | 61 | if ($default === null) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @throws \InvalidArgumentException Incorrect lambda syntax. |
| 81 | 81 | * @throws \InvalidArgumentException Incorrect SORT_ flags. |
| 82 | 82 | */ |
| 83 | - public static function createComparer ($closure, $sortOrder, &$isReversed) |
|
| 83 | + public static function createComparer($closure, $sortOrder, &$isReversed) |
|
| 84 | 84 | { |
| 85 | 85 | if ($closure === null) { |
| 86 | 86 | $isReversed = false; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param int|bool $sortOrder |
| 117 | 117 | * @return callable|string|int|null |
| 118 | 118 | */ |
| 119 | - public static function lambdaToSortFlagsAndOrder ($closure, &$sortOrder) |
|
| 119 | + public static function lambdaToSortFlagsAndOrder($closure, &$sortOrder) |
|
| 120 | 120 | { |
| 121 | 121 | if ($sortOrder !== SORT_ASC && $sortOrder !== SORT_DESC) |
| 122 | 122 | $sortOrder = $sortOrder ? SORT_DESC : SORT_ASC; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @throws \InvalidArgumentException Incorrect lambda syntax. |
| 136 | 136 | * @return string|null |
| 137 | 137 | */ |
| 138 | - private static function createLambdaFromString ($closure, $closureArgs) |
|
| 138 | + private static function createLambdaFromString($closure, $closureArgs) |
|
| 139 | 139 | { |
| 140 | 140 | $posDollar = strpos($closure, '$'); |
| 141 | 141 | if ($posDollar !== false) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $code = substr($closure, $posArrow + 3); |
| 148 | 148 | } |
| 149 | 149 | else { |
| 150 | - $args = '$' . str_replace(',', '=null,$', $closureArgs) . '=null'; |
|
| 150 | + $args = '$'.str_replace(',', '=null,$', $closureArgs).'=null'; |
|
| 151 | 151 | $code = $closure; |
| 152 | 152 | } |
| 153 | 153 | $code = trim($code, " \r\n\t"); |