@@ -79,8 +79,8 @@ |
||
79 | 79 | */ |
80 | 80 | function averageTime($n, $path, $test) { |
81 | 81 | $s = 0; |
82 | - for ($i=0; $i < $n; $i++) { |
|
83 | - $s =+ execute($path, $test->input); |
|
82 | + for ($i = 0; $i < $n; $i ++) { |
|
83 | + $s = + execute($path, $test->input); |
|
84 | 84 | } |
85 | 85 | return $s / $n; |
86 | 86 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require __DIR__.'/../../vendor/autoload.php'; |
|
2 | +require __DIR__ . '/../../vendor/autoload.php'; |
|
3 | 3 | |
4 | 4 | use Tarsana\Functional as F; |
5 | 5 | use Tarsana\Functional\Stream; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | $words = []; |
8 | 8 | foreach ($text as $word => $occ) { |
9 | - if (! isset($words[$occ])) { |
|
9 | + if (!isset($words[$occ])) { |
|
10 | 10 | $words[$occ] = []; |
11 | 11 | } |
12 | 12 | $words[$occ][] = $word; |
@@ -8,10 +8,10 @@ |
||
8 | 8 | */ |
9 | 9 | class Placeholder { |
10 | 10 | private static $instance; |
11 | - private function __construct(){} |
|
11 | + private function __construct() {} |
|
12 | 12 | public static function get() |
13 | 13 | { |
14 | - if(static::$instance === null) |
|
14 | + if (static::$instance === null) |
|
15 | 15 | static::$instance = new Placeholder; |
16 | 16 | return static::$instance; |
17 | 17 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param mixed $something |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function toString () { |
|
117 | +function toString() { |
|
118 | 118 | static $toString = false; |
119 | 119 | $toString = $toString ?: curry(function($something) { |
120 | 120 | switch (type($something)) { |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | return $something->__toString(); |
138 | 138 | case 'Object': |
139 | 139 | case 'Array': |
140 | - return '{' . join(', ', map(function($pair){ |
|
141 | - return $pair[0].': '. toString($pair[1]); |
|
140 | + return '{' . join(', ', map(function($pair) { |
|
141 | + return $pair[0] . ': ' . toString($pair[1]); |
|
142 | 142 | }, toPairs($something))) . '}'; |
143 | 143 | default: |
144 | - return '['.type($something).']'; |
|
144 | + return '[' . type($something) . ']'; |
|
145 | 145 | } |
146 | 146 | }); |
147 | 147 | return _apply($toString, func_get_args()); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function curry($fn) { |
39 | 39 | $n = _number_of_args($fn); |
40 | - switch($n) { |
|
40 | + switch ($n) { |
|
41 | 41 | case 0: return $fn; |
42 | 42 | case 1: return _curry_one($fn); |
43 | 43 | case 2: return _curry_two($fn); |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function pipe() { |
114 | 114 | $fns = func_get_args(); |
115 | - if(count($fns) < 1) |
|
115 | + if (count($fns) < 1) |
|
116 | 116 | return identity(); |
117 | - return function () use ($fns) { |
|
117 | + return function() use ($fns) { |
|
118 | 118 | $result = _apply(array_shift($fns), func_get_args()); |
119 | 119 | foreach ($fns as $fn) { |
120 | 120 | $result = $fn($result); |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | */ |
144 | 144 | function compose() { |
145 | 145 | $fns = array_reverse(func_get_args()); |
146 | - if(count($fns) < 1) |
|
146 | + if (count($fns) < 1) |
|
147 | 147 | return identity(); |
148 | - return function () use ($fns) { |
|
148 | + return function() use ($fns) { |
|
149 | 149 | $result = _apply(array_shift($fns), func_get_args()); |
150 | 150 | foreach ($fns as $fn) { |
151 | 151 | $result = $fn($result); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $predicates = func_get_args(); |
223 | 223 | return _curry_one(function($value) use(&$predicates) { |
224 | 224 | foreach ($predicates as $predicate) { |
225 | - if (! $predicate($value)) |
|
225 | + if (!$predicate($value)) |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | return true; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | static $comparator = false; |
321 | 321 | $comparator = $comparator ?: curry(function($fn) { |
322 | 322 | return function($a, $b) use($fn) { |
323 | - if ($fn($a, $b)) return -1; |
|
323 | + if ($fn($a, $b)) return - 1; |
|
324 | 324 | if ($fn($b, $a)) return 1; |
325 | 325 | return 0; |
326 | 326 | }; |