Completed
Push — master ( 5a66ad...309b32 )
by Amine
01:58
created
src/Error.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param  Error|null $error
25 25
      * @return Error
26 26
      */
27
-    public static function of ($message, Error $error = null)
27
+    public static function of($message, Error $error = null)
28 28
     {
29 29
         return new Error($message, $error);
30 30
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @param string     $message
36 36
      * @param Error|null $error
37 37
      */
38
-    protected function __construct ($message, Error $error = null)
38
+    protected function __construct($message, Error $error = null)
39 39
     {
40 40
         if (null != $error)
41 41
             $message = $error->message() . ' -> ' . $message;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @signature Error -> String
53 53
      * @return string
54 54
      */
55
-    public function message ()
55
+    public function message()
56 56
     {
57 57
         return $this->message;
58 58
     }
Please login to merge, or discard this patch.
generate-docs.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 // Reads the list of sources files from 'composer.json'
18 18
 // * -> IO [String]
19 19
 function modules() {
20
-    $composer = json_decode(file_get_contents(__DIR__.'/composer.json'));
20
+    $composer = json_decode(file_get_contents(__DIR__ . '/composer.json'));
21 21
     return $composer->autoload->files;
22 22
 }
23 23
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @field type String
40 40
  */
41 41
 function argsOf($data) {
42
-    return F\map(function($tag){
42
+    return F\map(function($tag) {
43 43
         return (object) [
44 44
             'type' => $tag->name,
45 45
             'name' => $tag->description
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 // Extracts signatures of a function.
51 51
 // Object -> [String]
52 52
 function signaturesOf($data) {
53
-    return F\map(function($tag){
53
+    return F\map(function($tag) {
54 54
         return $tag->string;
55 55
     }, tags('signature', $data));
56 56
 }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 // Get a markdown code block
125 125
 // String -> String -> String
126 126
 function code($lang, $text) {
127
-    if(trim($text) == '')
127
+    if (trim($text) == '')
128 128
         return '';
129 129
     return "```{$lang}\n{$text}\n```";
130 130
 }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $args = F\map(function($arg) {
139 139
             return $arg->type . ' ' . $arg->name;
140 140
         }, $fn->args);
141
-        $proto = $fn->name . '('. F\join(', ', $args) .') : ' . $fn->return;
141
+        $proto = $fn->name . '(' . F\join(', ', $args) . ') : ' . $fn->return;
142 142
         return F\join("\n\n", [
143 143
             "## {$fn->name}",
144 144
             code('php', $proto),
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 function addContents() {
154 154
     $addContents = function($name, $parts) {
155 155
         $names = F\filter(F\notEq($name), F\map(F\value('name'), $parts));
156
-        $contents = F\map(function ($partname) use($name) {
156
+        $contents = F\map(function($partname) use($name) {
157 157
             $link = URL . "/docs/{$name}.md#{$partname}";
158 158
             return "- [{$partname}]($link)";
159 159
         }, $names);
160
-        file_put_contents ("docs/README.md",
160
+        file_put_contents("docs/README.md",
161 161
             F\join("\n\n", F\concat(["## {$name}"], $contents)) . "\n\n"
162 162
         , FILE_APPEND);
163 163
         return array_merge(['# ' . $name, '## Table Of Contents'], $contents, F\map(F\value('md'), $parts));
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 function generateModule($file) {
170 170
     $content = F\pipe(
171 171
         F\map('Demo\\block'),
172
-        F\filter(function($block){
172
+        F\filter(function($block) {
173 173
             return $block->type == 'function' && !$block->is_internal;
174 174
         }),
175
-        F\map(function($block){
175
+        F\map(function($block) {
176 176
             return [
177 177
                 'name' => $block->name,
178 178
                 'md' => markdown($block)
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         F\join("\n\n")
183 183
     );
184 184
 
185
-    file_put_contents (
185
+    file_put_contents(
186 186
         F\replace(['src', '.php'], ['docs', '.md'], $file),
187 187
         $content(json_decode(shell_exec("dox -r < {$file}")))
188 188
     );
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 function generateClass($name) {
194 194
     $content = F\pipe(
195 195
         F\map('Demo\\block'),
196
-        F\filter(function($block){
196
+        F\filter(function($block) {
197 197
             return in_array($block->type, ['method', 'class']) && !$block->is_internal;
198 198
         }),
199 199
         f\map(function($block) use ($name) {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             }
203 203
             return $block;
204 204
         }),
205
-        F\map(function($block){
205
+        F\map(function($block) {
206 206
             return [
207 207
                 'name' => $block->name,
208 208
                 'md' => markdown($block)
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         F\join("\n\n")
213 213
     );
214 214
 
215
-    file_put_contents (
215
+    file_put_contents(
216 216
         "docs/{$name}.md",
217 217
         $content(json_decode(shell_exec("dox -r < src/{$name}.php")))
218 218
     );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
 // The entry point
222 222
 file_put_contents('docs/README.md', "# Reference Documentation \n\n");
223
-file_put_contents ("docs/README.md", "# Function Modules\n\n" , FILE_APPEND);
223
+file_put_contents("docs/README.md", "# Function Modules\n\n", FILE_APPEND);
224 224
 F\each('Demo\\generateModule', modules());
225
-file_put_contents ("docs/README.md", "# Containers\n\n" , FILE_APPEND);
225
+file_put_contents("docs/README.md", "# Containers\n\n", FILE_APPEND);
226 226
 F\each('Demo\\generateClass', ['Stream', 'Error']);
Please login to merge, or discard this patch.
src/object.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  * @return bool
156 156
  */
157 157
 function has() {
158
-    $has = function($name, $object){
158
+    $has = function($name, $object) {
159 159
         return contains($name, keys($object));
160 160
     };
161 161
     return apply(curry($has), func_get_args());
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
  * @return mixed
186 186
  */
187 187
 function get() {
188
-    $get = function($name, $object){
188
+    $get = function($name, $object) {
189 189
         $object = attributes($object);
190 190
         return has($name, $object)
191 191
             ? $object[$name]
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
  * @return mixed
214 214
  */
215 215
 function getPath() {
216
-    $getPath = function($path, $object){
216
+    $getPath = function($path, $object) {
217 217
 
218 218
     };
219 219
     return apply(curry($getPath), func_get_args());
Please login to merge, or discard this patch.
src/operators.php 1 patch
Spacing   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @return bool
14 14
  */
15 15
 function and_() {
16
-    return apply(curry(function($a, $b){
16
+    return apply(curry(function($a, $b) {
17 17
         return $a && $b;
18 18
     }), func_get_args());
19 19
 }
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @return bool
28 28
  */
29 29
 function or_() {
30
-    return apply(curry(function($a, $b){
30
+    return apply(curry(function($a, $b) {
31 31
         return $a || $b;
32 32
     }), func_get_args());
33 33
 }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  * @return bool
56 56
  */
57 57
 function eq() {
58
-    return apply(curry(function($a, $b){
58
+    return apply(curry(function($a, $b) {
59 59
         return $a == $b;
60 60
     }), func_get_args());
61 61
 }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return bool
70 70
  */
71 71
 function notEq() {
72
-    return apply(curry(function($a, $b){
72
+    return apply(curry(function($a, $b) {
73 73
         return $a != $b;
74 74
     }), func_get_args());
75 75
 }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  * @return bool
84 84
  */
85 85
 function eqq() {
86
-    return apply(curry(function($a, $b){
86
+    return apply(curry(function($a, $b) {
87 87
         return $a === $b;
88 88
     }), func_get_args());
89 89
 }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  * @return bool
98 98
  */
99 99
 function notEqq() {
100
-    return apply(curry(function($a, $b){
100
+    return apply(curry(function($a, $b) {
101 101
         return $a !== $b;
102 102
     }), func_get_args());
103 103
 }
@@ -140,9 +140,7 @@  discard block
 block discarded – undo
140 140
                     return $a == $b;
141 141
                 case 'List':
142 142
                     $length = length($a);
143
-                    return length($b) != $length ? false :
144
-                           0 == $length ? true :
145
-                           equals(head($a), head($b)) && equals(tail($a), tail($b));
143
+                    return length($b) != $length ? false : 0 == $length ? true : equals(head($a), head($b)) && equals(tail($a), tail($b));
146 144
                 case 'Array':
147 145
                 case 'ArrayObject':
148 146
                 case 'Object':
@@ -162,7 +160,7 @@  discard block
 block discarded – undo
162 160
  * @return bool
163 161
  */
164 162
 function lt() {
165
-    return apply(curry(function($a, $b){
163
+    return apply(curry(function($a, $b) {
166 164
         return $a < $b;
167 165
     }), func_get_args());
168 166
 }
@@ -176,7 +174,7 @@  discard block
 block discarded – undo
176 174
  * @return bool
177 175
  */
178 176
 function lte() {
179
-    return apply(curry(function($a, $b){
177
+    return apply(curry(function($a, $b) {
180 178
         return $a <= $b;
181 179
     }), func_get_args());
182 180
 }
@@ -190,7 +188,7 @@  discard block
 block discarded – undo
190 188
  * @return bool
191 189
  */
192 190
 function gt() {
193
-    return apply(curry(function($a, $b){
191
+    return apply(curry(function($a, $b) {
194 192
         return $a > $b;
195 193
     }), func_get_args());
196 194
 }
@@ -204,7 +202,7 @@  discard block
 block discarded – undo
204 202
  * @return bool
205 203
  */
206 204
 function gte() {
207
-    return apply(curry(function($a, $b){
205
+    return apply(curry(function($a, $b) {
208 206
         return $a >= $b;
209 207
     }), func_get_args());
210 208
 }
Please login to merge, or discard this patch.
src/Placeholder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@
 block discarded – undo
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
     }
18
-    public function __toString(){
18
+    public function __toString() {
19 19
         return '__';
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 function _number_of_args($fn) {
30 30
     $reflector = is_array($fn) ?
31
-        new \ReflectionMethod($fn[0], $fn[1]) :
32
-        new \ReflectionFunction($fn);
31
+        new \ReflectionMethod($fn[0], $fn[1]) : new \ReflectionFunction($fn);
33 32
     return $reflector->getNumberOfRequiredParameters();
34 33
 }
35 34
 
@@ -59,7 +58,7 @@  discard block
 block discarded – undo
59 58
     $addArgument = function($currentBoundArgs, $arg) use($fnArgsCount) {
60 59
         $currentBoundArgsCount = count($currentBoundArgs);
61 60
         $placeholderPosition = 0;
62
-        while($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition]))
61
+        while ($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition]))
63 62
             $placeholderPosition ++;
64 63
         if ($currentBoundArgsCount < $fnArgsCount || $placeholderPosition == $currentBoundArgsCount) {
65 64
             $currentBoundArgs[] = $arg;
@@ -179,9 +178,9 @@  discard block
 block discarded – undo
179 178
  */
180 179
 function pipe() {
181 180
     $fns = func_get_args();
182
-    if(count($fns) < 1)
181
+    if (count($fns) < 1)
183 182
         throw new InvalidArgument("pipe() requires at least one argument");
184
-    return curry(function () use ($fns) {
183
+    return curry(function() use ($fns) {
185 184
         $result = _apply(array_shift($fns), func_get_args());
186 185
         foreach ($fns as $fn) {
187 186
             $result = $fn($result);
Please login to merge, or discard this patch.
src/Stream.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param  mixed $data
82 82
      * @return Stream
83 83
      */
84
-    public static function of ($data)
84
+    public static function of($data)
85 85
     {
86 86
         $data = func_get_args();
87 87
         if (count($data) == 1)
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param  array $operations
97 97
      * @return Stream
98 98
      */
99
-    protected static function with ($data, $operations, $type)
99
+    protected static function with($data, $operations, $type)
100 100
     {
101 101
         return new Stream($data, $operations, $type);
102 102
     }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * @param  array $operations
108 108
      * @return array|Error
109 109
      */
110
-    protected static function optimize ($operations)
110
+    protected static function optimize($operations)
111 111
     {
112 112
         // TODO: ...
113 113
         return $operations;
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
      * @param  mixed $data
121 121
      * @return mixed|Error
122 122
      */
123
-    protected static function execute ($operations, $data)
123
+    protected static function execute($operations, $data)
124 124
     {
125 125
         if (length($operations) == 0)
126 126
             return $data;
127
-        $operations = apply(_f('pipe'), map(function($operation){
127
+        $operations = apply(_f('pipe'), map(function($operation) {
128 128
             if ($operation['name'] == 'apply') {
129 129
                 return $operation['args'];
130 130
             }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      * @param  string $type
143 143
      * @return bool
144 144
      */
145
-    protected static function canApply ($operation, $type)
145
+    protected static function canApply($operation, $type)
146 146
     {
147 147
         return isset(Stream::$transformations[$operation]) && (
148 148
             $type == 'Unknown' ||
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      * @param  string $type
159 159
      * @return bool
160 160
      */
161
-    protected static function returnOf ($operation, $type)
161
+    protected static function returnOf($operation, $type)
162 162
     {
163 163
         return isset(Stream::$transformations[$operation][$type])
164 164
             ? Stream::$transformations[$operation][$type]
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
      * @param  Stream $stream
174 174
      * @return Stream
175 175
      */
176
-    protected static function apply ($operation, $args, $stream)
176
+    protected static function apply($operation, $args, $stream)
177 177
     {
178 178
         if ($stream->type == 'Error') {
179 179
             return Stream::of(Error::of("Could not apply {$operation} to {$stream->type}", $stream->data));
180 180
         }
181
-        if (! Stream::canApply($operation, $stream->type)) {
181
+        if (!Stream::canApply($operation, $stream->type)) {
182 182
             $data = toString($stream->data);
183 183
             return Stream::of(Error::of("Could not apply {$operation} to {$stream->type}({$data})"));
184 184
         }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      *
195 195
      * @param mixed $data
196 196
      */
197
-    protected function __construct ($data, $operations, $type)
197
+    protected function __construct($data, $operations, $type)
198 198
     {
199 199
         $this->data = $data;
200 200
         $this->type = $type;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @signature Stream(a) -> a
233 233
      * @return mixed
234 234
      */
235
-    public function get ()
235
+    public function get()
236 236
     {
237 237
         if ($this->type == 'Error')
238 238
             return $this->data;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @param  callable $fn
252 252
      * @return Stream
253 253
      */
254
-    public function map (callable $fn)
254
+    public function map(callable $fn)
255 255
     {
256 256
         return Stream::apply('map', [$fn], $this);
257 257
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @param  callable $predicate
269 269
      * @return Stream
270 270
      */
271
-    public function filter (callable $predicate)
271
+    public function filter(callable $predicate)
272 272
     {
273 273
         return Stream::apply('filter', [$predicate], $this);
274 274
     }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      * @param mixed $initial
287 287
      * @return Stream
288 288
      */
289
-    public function reduce ($fn, $initial)
289
+    public function reduce($fn, $initial)
290 290
     {
291 291
         return Stream::apply('reduce', [$fn, $initial], $this);
292 292
     }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      * @param callable $fn
306 306
      * @return Stream
307 307
      */
308
-    public function chain ($fn)
308
+    public function chain($fn)
309 309
     {
310 310
         return Stream::apply('chain', [$fn], $this);
311 311
     }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * @signature Stream(String) -> Number
326 326
      * @return Stream
327 327
      */
328
-    public function length ()
328
+    public function length()
329 329
     {
330 330
         return Stream::apply('length', [], $this);
331 331
     }
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      * @param int $number
347 347
      * @return Stream
348 348
      */
349
-    public function take ($number)
349
+    public function take($number)
350 350
     {
351 351
         return Stream::apply('take', [$number], $this);
352 352
     }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      * @param callable $fn
368 368
      * @return Stream
369 369
      */
370
-    public function then ($fn)
370
+    public function then($fn)
371 371
     {
372 372
         $result = $this;
373 373
         foreach (func_get_args() as $fn) {
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      * @param  mixed|null $args...
418 418
      * @return Stream
419 419
      */
420
-    public function call ($method)
420
+    public function call($method)
421 421
     {
422 422
         $args = tail(func_get_args());
423 423
         return Stream::apply('apply', function($data) use($method, $args) {
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
      * @param  mixed|null $args...
472 472
      * @return Stream
473 473
      */
474
-    public function run ($method)
474
+    public function run($method)
475 475
     {
476 476
         $args = tail(func_get_args());
477 477
         return Stream::apply('apply', function($data) use($method, $args) {
Please login to merge, or discard this patch.
src/list.php 1 patch
Spacing   +17 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
  * @return array
57 57
  */
58 58
 function filter() {
59
-    $filter = function($fn, $list){
59
+    $filter = function($fn, $list) {
60 60
         return array_values(array_filter($list, $fn));
61 61
     };
62 62
     return apply(curry($filter), func_get_args());
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  * @return array
79 79
  */
80 80
 function reduce() {
81
-    $reduce = function($fn, $initial, $list){
81
+    $reduce = function($fn, $initial, $list) {
82 82
         return array_reduce($list, $fn, $initial);
83 83
     };
84 84
     return apply(curry($reduce), func_get_args());
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  * @return array
105 105
  */
106 106
 function each() {
107
-    $each = function($fn, $list){
107
+    $each = function($fn, $list) {
108 108
         foreach ($list as $item) {
109 109
             apply($fn, [$item]);
110 110
         }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
  * @return mixed
129 129
  */
130 130
 function head($list) {
131
-    if(is_string($list))
131
+    if (is_string($list))
132 132
         return substr($list, 0, 1);
133 133
     return (count($list) > 0)
134 134
         ? $list[0]
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
  * @return mixed
151 151
  */
152 152
 function last($list) {
153
-    if(is_string($list))
153
+    if (is_string($list))
154 154
         return substr($list, -1);
155 155
     return (count($list) > 0)
156 156
         ? $list[count($list) - 1]
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  * @return array
174 174
  */
175 175
 function init($list) {
176
-    if(is_string($list))
176
+    if (is_string($list))
177 177
         return (strlen($list) > 1)
178 178
             ? substr($list, 0, strlen($list) - 1)
179 179
             : '';
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
  * @return array
199 199
  */
200 200
 function tail($list) {
201
-    if(is_string($list))
201
+    if (is_string($list))
202 202
         return (strlen($list) > 1)
203 203
             ? substr($list, 1)
204 204
             : '';
@@ -322,8 +322,7 @@  discard block
 block discarded – undo
322 322
  */
323 323
 function concatAll() {
324 324
     $concatAll = function($lists) {
325
-        return length($lists) == 0 ? [] :
326
-            reduce(concat(), head($lists), tail($lists));
325
+        return length($lists) == 0 ? [] : reduce(concat(), head($lists), tail($lists));
327 326
     };
328 327
     return apply(curry($concatAll), func_get_args());
329 328
 }
@@ -402,7 +401,7 @@  discard block
 block discarded – undo
402 401
  * @return array
403 402
  */
404 403
 function append() {
405
-    $append = function ($item, $list) {
404
+    $append = function($item, $list) {
406 405
         return insert(length($list), $item, $list);
407 406
     };
408 407
     return apply(curry($append), func_get_args());
@@ -449,7 +448,7 @@  discard block
 block discarded – undo
449 448
         $length = length($list);
450 449
         if ($count > $length || $count < -$length)
451 450
             return [];
452
-        if(is_string($list)) {
451
+        if (is_string($list)) {
453 452
             return ($count >= 0)
454 453
                 ? substr($list, 0, $count)
455 454
                 : substr($list, $count);
@@ -705,9 +704,9 @@  discard block
 block discarded – undo
705 704
  */
706 705
 function slices() {
707 706
     $slices = function($size, $list) {
708
-        if(empty($list))
707
+        if (empty($list))
709 708
             return is_string($list) ? '' : [];
710
-        if(length($list) <= $size)
709
+        if (length($list) <= $size)
711 710
             return [$list];
712 711
         return prepend(take($size, $list), slices($size, remove($size, $list)));
713 712
     };
@@ -731,7 +730,7 @@  discard block
 block discarded – undo
731 730
  */
732 731
 function contains() {
733 732
     $contains = function($item, $list) {
734
-        return -1 != indexOf($item, $list);
733
+        return - 1 != indexOf($item, $list);
735 734
     };
736 735
     return apply(curry($contains), func_get_args());
737 736
 }
@@ -780,7 +779,7 @@  discard block
 block discarded – undo
780 779
 function findLastIndex() {
781 780
     $findLastIndex = function($predicate, $list) {
782 781
         foreach (reverse(toPairs($list)) as $pair) {
783
-            if($predicate($pair[1]))
782
+            if ($predicate($pair[1]))
784 783
                 return $pair[0];
785 784
         }
786 785
         return null;
@@ -857,7 +856,7 @@  discard block
 block discarded – undo
857 856
             $index = findIndex(equals($item), $list);
858 857
         }
859 858
         return (false === $index || null === $index)
860
-            ? -1
859
+            ? - 1
861 860
             : $index;
862 861
     };
863 862
     return apply(curry($indexOf), func_get_args());
@@ -887,7 +886,7 @@  discard block
 block discarded – undo
887 886
             $index = findLastIndex(equals($item), $list);
888 887
         }
889 888
         return (false === $index || null === $index)
890
-            ? -1
889
+            ? - 1
891 890
             : $index;
892 891
     };
893 892
     return apply(curry($lastIndexOf), func_get_args());
@@ -972,7 +971,7 @@  discard block
 block discarded – undo
972 971
     $groupBy = function($fn, $list) {
973 972
         return reduce(function($result, $item) use($fn) {
974 973
             $index = $fn($item);
975
-            if (! isset($result[$index]))
974
+            if (!isset($result[$index]))
976 975
                 $result[$index] = [];
977 976
             $result[$index][] = $item;
978 977
             return $result;
Please login to merge, or discard this patch.
src/common.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
  * @param  mixed $something
83 83
  * @return string
84 84
  */
85
-function toString () {
85
+function toString() {
86 86
     $toString = function($something) {
87 87
         switch (type($something)) {
88 88
             case 'String':
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
                 return $something->__toString();
106 106
             case 'Object':
107 107
             case 'Array':
108
-                return '{' . join(', ', map(function($pair){
109
-                    return $pair[0].': '. toString($pair[1]);
108
+                return '{' . join(', ', map(function($pair) {
109
+                    return $pair[0] . ': ' . toString($pair[1]);
110 110
                 }, toPairs($something))) . '}';
111 111
             default:
112
-                return '['.type($something).']';
112
+                return '[' . type($something) . ']';
113 113
         }
114 114
     };
115 115
     return apply(curry($toString), func_get_args());
Please login to merge, or discard this patch.