Completed
Pull Request — master (#12)
by Siwapun
01:40
created
test/IdentityTest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 
8 8
 class IdentityTest extends TestCase
9 9
 {
10
-  public function testIdentity()
11
-  {
10
+    public function testIdentity()
11
+    {
12 12
     $value = new PlainObjectAsset();
13 13
     $actual = identity()($value);
14 14
     $this->assertSame($value, $actual);
15
-  }
15
+    }
16 16
 }
Please login to merge, or discard this patch.
src/function.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
  */
8 8
 function always()
9 9
 {
10
-  $always = function ($data) {
10
+    $always = function ($data) {
11 11
     return function () use ($data) {
12
-      return $data;
12
+        return $data;
13 13
     };
14
-  };
15
-  $arguments = func_get_args();
16
-  $curried = curryN($always, 1);
17
-  return call_user_func_array($curried, $arguments);
14
+    };
15
+    $arguments = func_get_args();
16
+    $curried = curryN($always, 1);
17
+    return call_user_func_array($curried, $arguments);
18 18
 }
19 19
 
20 20
 /**
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function apply()
26 26
 {
27
-  $apply = function (callable $fn, array $args) {
27
+    $apply = function (callable $fn, array $args) {
28 28
     return call_user_func_array($fn, $args);
29
-  };
30
-  $arguments = func_get_args();
31
-  $curried = curryN($apply, 2);
32
-  return call_user_func_array($curried, $arguments);
29
+    };
30
+    $arguments = func_get_args();
31
+    $curried = curryN($apply, 2);
32
+    return call_user_func_array($curried, $arguments);
33 33
 }
34 34
 
35 35
 /**
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function call()
41 41
 {
42
-  $arguments = func_get_args();
43
-  $length = count($arguments);
44
-  switch ($length) {
42
+    $arguments = func_get_args();
43
+    $length = count($arguments);
44
+    switch ($length) {
45 45
     case 0:
46 46
           return __FUNCTION__;
47 47
     case 1:
48 48
       $fn = $arguments[0];
49
-          return function (...$arguments) use ($fn) {
49
+            return function (...$arguments) use ($fn) {
50 50
             return call_user_func_array($fn, $arguments);
51
-          };
51
+            };
52 52
     default:
53 53
       $fn = $arguments[0];
54
-      $arguments = dropFirst($arguments);
55
-          return call_user_func_array($fn, $arguments);
56
-  }
54
+        $arguments = dropFirst($arguments);
55
+            return call_user_func_array($fn, $arguments);
56
+    }
57 57
 }
58 58
 
59 59
 /**
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function compose()
64 64
 {
65
-  $arguments = array_reverse(func_get_args());
66
-  return call_user_func_array('Aerophant\Ramda\pipe', $arguments);
65
+    $arguments = array_reverse(func_get_args());
66
+    return call_user_func_array('Aerophant\Ramda\pipe', $arguments);
67 67
 }
68 68
 
69 69
 /**
@@ -72,37 +72,37 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function construct()
74 74
 {
75
-  $construct = function ($class) {
75
+    $construct = function ($class) {
76 76
     return function () use ($class) {
77
-      return new $class();
77
+        return new $class();
78 78
     };
79
-  };
80
-  $arguments = func_get_args();
81
-  $curried = curryN($construct, 1);
82
-  return call_user_func_array($curried, $arguments);
79
+    };
80
+    $arguments = func_get_args();
81
+    $curried = curryN($construct, 1);
82
+    return call_user_func_array($curried, $arguments);
83 83
 }
84 84
 
85 85
 function curryN(callable $fn, int $numberOfArguments)
86 86
 {
87
-  return function () use ($fn, $numberOfArguments) {
87
+    return function () use ($fn, $numberOfArguments) {
88 88
     $arguments = func_get_args();
89 89
     $length = count($arguments);
90 90
     if ($length > $numberOfArguments) {
91
-      throw new \InvalidArgumentException(
91
+        throw new \InvalidArgumentException(
92 92
         "Number of passed($length) parameters is greater than expected($numberOfArguments)"
93
-      );
93
+        );
94 94
     }
95 95
     // NO CURRY
96 96
     if ($length == $numberOfArguments) {
97
-      return call_user_func_array($fn, $arguments);
97
+        return call_user_func_array($fn, $arguments);
98 98
     }
99 99
     // AUTO CURRY
100 100
     $curriedFn = function () use ($fn, $arguments) {
101
-      $curriedArguments = func_get_args();
102
-      return call_user_func_array($fn, array_merge($arguments, $curriedArguments));
101
+        $curriedArguments = func_get_args();
102
+        return call_user_func_array($fn, array_merge($arguments, $curriedArguments));
103 103
     };
104 104
     return curryN($curriedFn, $numberOfArguments - $length);
105
-  };
105
+    };
106 106
 }
107 107
 
108 108
 /**
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function identity()
113 113
 {
114
-  $identity = function ($value) {
114
+    $identity = function ($value) {
115 115
     return $value;
116
-  };
117
-  $arguments = func_get_args();
118
-  $curried = curryN($identity, 1);
119
-  return call_user_func_array($curried, $arguments);
116
+    };
117
+    $arguments = func_get_args();
118
+    $curried = curryN($identity, 1);
119
+    return call_user_func_array($curried, $arguments);
120 120
 }
121 121
 
122 122
 /**
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function partial(callable $fn, array $args)
129 129
 {
130
-  return function () use ($fn, $args) {
130
+    return function () use ($fn, $args) {
131 131
     $arguments = func_get_args();
132 132
     return call_user_func_array($fn, array_merge($args, $arguments));
133
-  };
133
+    };
134 134
 }
135 135
 
136 136
 /**
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
  */
142 142
 function partialRight(callable $fn, array $args)
143 143
 {
144
-  return function () use ($fn, $args) {
144
+    return function () use ($fn, $args) {
145 145
     $arguments = func_get_args();
146 146
     return call_user_func_array($fn, array_merge($arguments, $args));
147
-  };
147
+    };
148 148
 }
149 149
 
150 150
 /**
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
  */
154 154
 function pipe()
155 155
 {
156
-  $arguments = func_get_args();
157
-  $length = count($arguments);
158
-  if ($length === 0) {
156
+    $arguments = func_get_args();
157
+    $length = count($arguments);
158
+    if ($length === 0) {
159 159
     throw new \Exception("pipe requires at least one argument");
160
-  }
161
-  return function () use ($arguments) {
160
+    }
161
+    return function () use ($arguments) {
162 162
     $internalArguments = func_get_args();
163 163
     $initialValue = call_user_func_array($arguments[0], $internalArguments);
164 164
     $accumulator = function ($acc, $it) {
165
-      return call_user_func_array($it, [$acc]);
165
+        return call_user_func_array($it, [$acc]);
166 166
     };
167 167
     return array_reduce(drop(0, $arguments), $accumulator, $initialValue);
168
-  };
168
+    };
169 169
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
 function always()
9 9
 {
10
-  $always = function ($data) {
11
-    return function () use ($data) {
10
+  $always = function($data) {
11
+    return function() use ($data) {
12 12
       return $data;
13 13
     };
14 14
   };
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function apply()
26 26
 {
27
-  $apply = function (callable $fn, array $args) {
27
+  $apply = function(callable $fn, array $args) {
28 28
     return call_user_func_array($fn, $args);
29 29
   };
30 30
   $arguments = func_get_args();
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
           return __FUNCTION__;
47 47
     case 1:
48 48
       $fn = $arguments[0];
49
-          return function (...$arguments) use ($fn) {
49
+          return function(...$arguments) use ($fn) {
50 50
             return call_user_func_array($fn, $arguments);
51 51
           };
52 52
     default:
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function construct()
74 74
 {
75
-  $construct = function ($class) {
76
-    return function () use ($class) {
75
+  $construct = function($class) {
76
+    return function() use ($class) {
77 77
       return new $class();
78 78
     };
79 79
   };
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 function curryN(callable $fn, int $numberOfArguments)
86 86
 {
87
-  return function () use ($fn, $numberOfArguments) {
87
+  return function() use ($fn, $numberOfArguments) {
88 88
     $arguments = func_get_args();
89 89
     $length = count($arguments);
90 90
     if ($length > $numberOfArguments) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
       return call_user_func_array($fn, $arguments);
98 98
     }
99 99
     // AUTO CURRY
100
-    $curriedFn = function () use ($fn, $arguments) {
100
+    $curriedFn = function() use ($fn, $arguments) {
101 101
       $curriedArguments = func_get_args();
102 102
       return call_user_func_array($fn, array_merge($arguments, $curriedArguments));
103 103
     };
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function identity()
113 113
 {
114
-  $identity = function ($value) {
114
+  $identity = function($value) {
115 115
     return $value;
116 116
   };
117 117
   $arguments = func_get_args();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function partial(callable $fn, array $args)
129 129
 {
130
-  return function () use ($fn, $args) {
130
+  return function() use ($fn, $args) {
131 131
     $arguments = func_get_args();
132 132
     return call_user_func_array($fn, array_merge($args, $arguments));
133 133
   };
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  */
142 142
 function partialRight(callable $fn, array $args)
143 143
 {
144
-  return function () use ($fn, $args) {
144
+  return function() use ($fn, $args) {
145 145
     $arguments = func_get_args();
146 146
     return call_user_func_array($fn, array_merge($arguments, $args));
147 147
   };
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
   if ($length === 0) {
159 159
     throw new \Exception("pipe requires at least one argument");
160 160
   }
161
-  return function () use ($arguments) {
161
+  return function() use ($arguments) {
162 162
     $internalArguments = func_get_args();
163 163
     $initialValue = call_user_func_array($arguments[0], $internalArguments);
164
-    $accumulator = function ($acc, $it) {
164
+    $accumulator = function($acc, $it) {
165 165
       return call_user_func_array($it, [$acc]);
166 166
     };
167 167
     return array_reduce(drop(0, $arguments), $accumulator, $initialValue);
Please login to merge, or discard this patch.
src/relation.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function equals()
10 10
 {
11
-  $equals = function ($a, $b) {
11
+    $equals = function ($a, $b) {
12 12
     return $a == $b;
13
-  };
14
-  $arguments = func_get_args();
15
-  $curried = curryN($equals, 2);
16
-  return call_user_func_array($curried, $arguments);
13
+    };
14
+    $arguments = func_get_args();
15
+    $curried = curryN($equals, 2);
16
+    return call_user_func_array($curried, $arguments);
17 17
 }
18 18
 
19 19
 function gt()
20 20
 {
21
-  $gt = function ($a, $b) {
21
+    $gt = function ($a, $b) {
22 22
     return $a > $b;
23
-  };
24
-  $arguments = func_get_args();
25
-  $curried = curryN($gt, 2);
26
-  return call_user_func_array($curried, $arguments);
23
+    };
24
+    $arguments = func_get_args();
25
+    $curried = curryN($gt, 2);
26
+    return call_user_func_array($curried, $arguments);
27 27
 }
28 28
 
29 29
 function gte()
30 30
 {
31
-  $gte = function ($a, $b) {
31
+    $gte = function ($a, $b) {
32 32
     return $a >= $b;
33
-  };
34
-  $arguments = func_get_args();
35
-  $curried = curryN($gte, 2);
36
-  return call_user_func_array($curried, $arguments);
33
+    };
34
+    $arguments = func_get_args();
35
+    $curried = curryN($gte, 2);
36
+    return call_user_func_array($curried, $arguments);
37 37
 }
38 38
 
39 39
 /**
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function identical()
46 46
 {
47
-  $identical = function ($firstValue, $secondValue) {
47
+    $identical = function ($firstValue, $secondValue) {
48 48
     return $firstValue === $secondValue;
49
-  };
50
-  $arguments = func_get_args();
51
-  $curried = curryN($identical, 2);
52
-  return call_user_func_array($curried, $arguments);
49
+    };
50
+    $arguments = func_get_args();
51
+    $curried = curryN($identical, 2);
52
+    return call_user_func_array($curried, $arguments);
53 53
 }
54 54
 
55 55
 function lt()
56 56
 {
57
-  $lt = function ($a, $b) {
57
+    $lt = function ($a, $b) {
58 58
     return $a < $b;
59
-  };
60
-  $arguments = func_get_args();
61
-  $curried = curryN($lt, 2);
62
-  return call_user_func_array($curried, $arguments);
59
+    };
60
+    $arguments = func_get_args();
61
+    $curried = curryN($lt, 2);
62
+    return call_user_func_array($curried, $arguments);
63 63
 }
64 64
 
65 65
 function lte()
66 66
 {
67
-  $lte = function ($a, $b) {
67
+    $lte = function ($a, $b) {
68 68
     return $a <= $b;
69
-  };
70
-  $arguments = func_get_args();
71
-  $curried = curryN($lte, 2);
72
-  return call_user_func_array($curried, $arguments);
69
+    };
70
+    $arguments = func_get_args();
71
+    $curried = curryN($lte, 2);
72
+    return call_user_func_array($curried, $arguments);
73 73
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function equals()
10 10
 {
11
-  $equals = function ($a, $b) {
11
+  $equals = function($a, $b) {
12 12
     return $a == $b;
13 13
   };
14 14
   $arguments = func_get_args();
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 function gt()
20 20
 {
21
-  $gt = function ($a, $b) {
21
+  $gt = function($a, $b) {
22 22
     return $a > $b;
23 23
   };
24 24
   $arguments = func_get_args();
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 function gte()
30 30
 {
31
-  $gte = function ($a, $b) {
31
+  $gte = function($a, $b) {
32 32
     return $a >= $b;
33 33
   };
34 34
   $arguments = func_get_args();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function identical()
46 46
 {
47
-  $identical = function ($firstValue, $secondValue) {
47
+  $identical = function($firstValue, $secondValue) {
48 48
     return $firstValue === $secondValue;
49 49
   };
50 50
   $arguments = func_get_args();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 function lt()
56 56
 {
57
-  $lt = function ($a, $b) {
57
+  $lt = function($a, $b) {
58 58
     return $a < $b;
59 59
   };
60 60
   $arguments = func_get_args();
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 function lte()
66 66
 {
67
-  $lte = function ($a, $b) {
67
+  $lte = function($a, $b) {
68 68
     return $a <= $b;
69 69
   };
70 70
   $arguments = func_get_args();
Please login to merge, or discard this patch.
test/FindTest.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 class FindTest extends TestCase
8 8
 {
9
-  public function testFindWithExistingValue()
10
-  {
9
+    public function testFindWithExistingValue()
10
+    {
11 11
     $isEqual3 = function ($it) {
12
-      return 3 == $it;
12
+        return 3 == $it;
13 13
     };
14 14
     $list = [1, 2, 3, 4, 5];
15 15
     $expect = 3;
16 16
     $actual = find($isEqual3)($list);
17 17
     $this->assertEquals($expect, $actual);
18
-  }
18
+    }
19 19
 
20
-  public function testFindWithNonExistingValue()
21
-  {
20
+    public function testFindWithNonExistingValue()
21
+    {
22 22
     $isEqual11 = function ($it) {
23
-      return 11 == $it;
23
+        return 11 == $it;
24 24
     };
25 25
     $list = [1, 2, 3, 4, 5];
26 26
     $actual = find($isEqual11)($list);
27 27
     $this->assertNull($actual);
28
-  }
28
+    }
29 29
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 {
9 9
   public function testFindWithExistingValue()
10 10
   {
11
-    $isEqual3 = function ($it) {
11
+    $isEqual3 = function($it) {
12 12
       return 3 == $it;
13 13
     };
14 14
     $list = [1, 2, 3, 4, 5];
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
   public function testFindWithNonExistingValue()
21 21
   {
22
-    $isEqual11 = function ($it) {
22
+    $isEqual11 = function($it) {
23 23
       return 11 == $it;
24 24
     };
25 25
     $list = [1, 2, 3, 4, 5];
Please login to merge, or discard this patch.
test/EndsWithTest.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,55 +6,55 @@
 block discarded – undo
6 6
 
7 7
 class EndsWithTest extends TestCase
8 8
 {
9
-  public function testEndsWithValidString()
10
-  {
9
+    public function testEndsWithValidString()
10
+    {
11 11
     $suffix = 'SomeKeyword';
12 12
     $list = 'StringWhichEndsWithSomeKeyword';
13 13
     $actual = endsWith($suffix)($list);
14 14
     $this->assertTrue($actual);
15
-  }
15
+    }
16 16
 
17
-  public function testEndsWithInvalidString()
18
-  {
17
+    public function testEndsWithInvalidString()
18
+    {
19 19
     $suffix = 'AnotherKeyword';
20 20
     $list = 'StringWhichEndsWithSomeKeyword';
21 21
     $actual = endsWith($suffix)($list);
22 22
     $this->assertFalse($actual);
23
-  }
23
+    }
24 24
 
25
-  public function testEndsWithEmptyString()
26
-  {
25
+    public function testEndsWithEmptyString()
26
+    {
27 27
     $suffix = '';
28 28
     $list = 'StringWhichEndsWithSomeKeyword';
29 29
     $actual = endsWith($suffix)($list);
30 30
     $this->assertTrue($actual);
31
-  }
31
+    }
32 32
 
33
-  public function testWithUnsupportedArguments()
34
-  {
33
+    public function testWithUnsupportedArguments()
34
+    {
35 35
     $this->expectException(\InvalidArgumentException::class);
36 36
     endsWith(1)('111');
37
-  }
37
+    }
38 38
 
39
-  public function testEndsWithEmptyArray()
40
-  {
39
+    public function testEndsWithEmptyArray()
40
+    {
41 41
     $suffix = [];
42 42
     $list = [1, 2 ,3, 4];
43 43
     $actual = endsWith($suffix)($list);
44 44
     $this->assertTrue($actual);
45
-  }
46
-  public function testEndsWithValidArray()
47
-  {
45
+    }
46
+    public function testEndsWithValidArray()
47
+    {
48 48
     $suffix = [4];
49 49
     $list = [1, 2 ,3, 4];
50 50
     $actual = endsWith($suffix)($list);
51 51
     $this->assertTrue($actual);
52
-  }
53
-  public function testEndsWithInvalidArray()
54
-  {
52
+    }
53
+    public function testEndsWithInvalidArray()
54
+    {
55 55
     $suffix = [5];
56 56
     $list = [1, 2 ,3, 4];
57 57
     $actual = endsWith($suffix)($list);
58 58
     $this->assertFalse($actual);
59
-  }
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,21 +39,21 @@
 block discarded – undo
39 39
   public function testEndsWithEmptyArray()
40 40
   {
41 41
     $suffix = [];
42
-    $list = [1, 2 ,3, 4];
42
+    $list = [1, 2, 3, 4];
43 43
     $actual = endsWith($suffix)($list);
44 44
     $this->assertTrue($actual);
45 45
   }
46 46
   public function testEndsWithValidArray()
47 47
   {
48 48
     $suffix = [4];
49
-    $list = [1, 2 ,3, 4];
49
+    $list = [1, 2, 3, 4];
50 50
     $actual = endsWith($suffix)($list);
51 51
     $this->assertTrue($actual);
52 52
   }
53 53
   public function testEndsWithInvalidArray()
54 54
   {
55 55
     $suffix = [5];
56
-    $list = [1, 2 ,3, 4];
56
+    $list = [1, 2, 3, 4];
57 57
     $actual = endsWith($suffix)($list);
58 58
     $this->assertFalse($actual);
59 59
   }
Please login to merge, or discard this patch.
test/GroupByTest.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 
7 7
 class GroupByTest extends TestCase
8 8
 {
9
-  public function testGroupByIsEven()
10
-  {
9
+    public function testGroupByIsEven()
10
+    {
11 11
     $isEven = function ($value) {
12
-      return $value % 2 === 0;
12
+        return $value % 2 === 0;
13 13
     };
14 14
     $expected = [
15
-      true => [2, 4, 6],
16
-      false => [1, 3, 5]
15
+        true => [2, 4, 6],
16
+        false => [1, 3, 5]
17 17
     ];
18 18
     $actual = groupBy($isEven)([1, 2, 3, 4, 5, 6]);
19 19
     $this->assertEquals($expected, $actual);
20
-  }
20
+    }
21 21
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
   public function testGroupByIsEven()
10 10
   {
11
-    $isEven = function ($value) {
11
+    $isEven = function($value) {
12 12
       return $value % 2 === 0;
13 13
     };
14 14
     $expected = [
Please login to merge, or discard this patch.
test/ArrayForEachTest.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
 class ArrayForEachTest extends TestCase
8 8
 {
9 9
 
10
-  public function testForEach()
11
-  {
10
+    public function testForEach()
11
+    {
12 12
     $list = [1, 2, 3];
13 13
     $mockFn = $this->createPartialMock(\stdClass::class, ['__invoke']);
14 14
     $mockFn->expects($this->exactly(3))
15
-      ->method('__invoke')
16
-      ->with($this->callback(function ($it) use ($list) {
15
+        ->method('__invoke')
16
+        ->with($this->callback(function ($it) use ($list) {
17 17
         return in_array($it, $list);
18
-      }));
18
+        }));
19 19
 
20 20
     arrayForEach($mockFn)($list);
21
-  }
21
+    }
22 22
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     $mockFn = $this->createPartialMock(\stdClass::class, ['__invoke']);
14 14
     $mockFn->expects($this->exactly(3))
15 15
       ->method('__invoke')
16
-      ->with($this->callback(function ($it) use ($list) {
16
+      ->with($this->callback(function($it) use ($list) {
17 17
         return in_array($it, $list);
18 18
       }));
19 19
 
Please login to merge, or discard this patch.
src/list.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function all()
10 10
 {
11
-  $all = function (callable $predicateFunction, array $array): bool {
11
+    $all = function (callable $predicateFunction, array $array): bool {
12 12
     if (empty($array)) {
13
-      return false;
13
+        return false;
14 14
     }
15 15
     foreach ($array as $it) {
16
-      if (!$predicateFunction($it)) {
16
+        if (!$predicateFunction($it)) {
17 17
         return false;
18
-      }
18
+        }
19 19
     }
20 20
     return true;
21
-  };
22
-  $arguments = func_get_args();
23
-  $curried = curryN($all, 2);
24
-  return call_user_func_array($curried, $arguments);
21
+    };
22
+    $arguments = func_get_args();
23
+    $curried = curryN($all, 2);
24
+    return call_user_func_array($curried, $arguments);
25 25
 }
26 26
 
27 27
 /**
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function any()
33 33
 {
34
-  $any = function (callable $predicateFunction, array $array) {
34
+    $any = function (callable $predicateFunction, array $array) {
35 35
     if (empty($array)) {
36
-      return false;
36
+        return false;
37 37
     }
38 38
     foreach ($array as $it) {
39
-      if ($predicateFunction($it)) {
39
+        if ($predicateFunction($it)) {
40 40
         return true;
41
-      }
41
+        }
42 42
     }
43 43
     return false;
44
-  };
45
-  $arguments = func_get_args();
46
-  $curriedAny = curryN($any, 2);
47
-  return call_user_func_array($curriedAny, $arguments);
44
+    };
45
+    $arguments = func_get_args();
46
+    $curriedAny = curryN($any, 2);
47
+    return call_user_func_array($curriedAny, $arguments);
48 48
 }
49 49
 
50 50
 /**
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function arrayForEach()
56 56
 {
57
-  $arrayForEach = function (callable $fn, array $array) {
57
+    $arrayForEach = function (callable $fn, array $array) {
58 58
     foreach ($array as $item) {
59
-      $fn($item);
59
+        $fn($item);
60 60
     }
61
-  };
62
-  $arguments = func_get_args();
63
-  $curriedAny = curryN($arrayForEach, 2);
64
-  return call_user_func_array($curriedAny, $arguments);
61
+    };
62
+    $arguments = func_get_args();
63
+    $curriedAny = curryN($arrayForEach, 2);
64
+    return call_user_func_array($curriedAny, $arguments);
65 65
 }
66 66
 
67 67
 /**
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function append()
74 74
 {
75
-  $append = function ($item, array $array) {
75
+    $append = function ($item, array $array) {
76 76
     return array_merge($array, [$item]);
77
-  };
78
-  $arguments = func_get_args();
79
-  $curriedAny = curryN($append, 2);
80
-  return call_user_func_array($curriedAny, $arguments);
77
+    };
78
+    $arguments = func_get_args();
79
+    $curriedAny = curryN($append, 2);
80
+    return call_user_func_array($curriedAny, $arguments);
81 81
 }
82 82
 
83 83
 /**
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function concat()
90 90
 {
91
-  $concat = function (array $firstArray, array $secondArray) {
91
+    $concat = function (array $firstArray, array $secondArray) {
92 92
     return array_merge($firstArray, $secondArray);
93
-  };
94
-  $arguments = func_get_args();
95
-  $curriedAny = curryN($concat, 2);
96
-  return call_user_func_array($curriedAny, $arguments);
93
+    };
94
+    $arguments = func_get_args();
95
+    $curriedAny = curryN($concat, 2);
96
+    return call_user_func_array($curriedAny, $arguments);
97 97
 }
98 98
 
99 99
 /**
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
  */
105 105
 function contains()
106 106
 {
107
-  $contains = partialRight('in_array', [true]);
108
-  $arguments = func_get_args();
109
-  $curriedAny = curryN($contains, 2);
110
-  return call_user_func_array($curriedAny, $arguments);
107
+    $contains = partialRight('in_array', [true]);
108
+    $arguments = func_get_args();
109
+    $curriedAny = curryN($contains, 2);
110
+    return call_user_func_array($curriedAny, $arguments);
111 111
 }
112 112
 
113 113
 /**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function drop()
119 119
 {
120
-  $drop = function (int $index, array $array) {
120
+    $drop = function (int $index, array $array) {
121 121
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
122
-  };
123
-  $arguments = func_get_args();
124
-  $curried = curryN($drop, 2);
125
-  return call_user_func_array($curried, $arguments);
122
+    };
123
+    $arguments = func_get_args();
124
+    $curried = curryN($drop, 2);
125
+    return call_user_func_array($curried, $arguments);
126 126
 }
127 127
 
128 128
 /**
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function dropFirst()
133 133
 {
134
-  $dropFirst = drop(0);
135
-  $arguments = func_get_args();
136
-  $curried = curryN($dropFirst, 1);
137
-  return call_user_func_array($curried, $arguments);
134
+    $dropFirst = drop(0);
135
+    $arguments = func_get_args();
136
+    $curried = curryN($dropFirst, 1);
137
+    return call_user_func_array($curried, $arguments);
138 138
 }
139 139
 
140 140
 /**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
  */
144 144
 function dropLast()
145 145
 {
146
-  $dropLast = function (array $array) {
146
+    $dropLast = function (array $array) {
147 147
     $index = count($array)-1;
148 148
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
149
-  };
149
+    };
150 150
 
151
-  $arguments = func_get_args();
152
-  $curried = curryN($dropLast, 1);
153
-  return call_user_func_array($curried, $arguments);
151
+    $arguments = func_get_args();
152
+    $curried = curryN($dropLast, 1);
153
+    return call_user_func_array($curried, $arguments);
154 154
 }
155 155
 
156 156
 /**
@@ -160,25 +160,25 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function endsWith()
162 162
 {
163
-  $endsWith = function ($suffix, $list) {
163
+    $endsWith = function ($suffix, $list) {
164 164
     if (is_string($suffix) && is_string($list)) {
165
-      return $suffix === '' || (($temp = strlen($list) - strlen($suffix)) >= 0 && strpos($list, $suffix) !== false);
165
+        return $suffix === '' || (($temp = strlen($list) - strlen($suffix)) >= 0 && strpos($list, $suffix) !== false);
166 166
     }
167 167
     if (is_array($suffix) && is_array($list)) {
168
-      $index = count($list) - count($suffix);
169
-      foreach ($suffix as $it) {
168
+        $index = count($list) - count($suffix);
169
+        foreach ($suffix as $it) {
170 170
         if ($it != $list[$index]) {
171
-          return false;
171
+            return false;
172 172
         }
173 173
         $index++;
174
-      }
175
-      return true;
174
+        }
175
+        return true;
176 176
     }
177 177
     throw new \InvalidArgumentException(__FUNCTION__ . 'accepts only string or array as it arguments');
178
-  };
179
-  $arguments = func_get_args();
180
-  $curried = curryN($endsWith, 2);
181
-  return call_user_func_array($curried, $arguments);
178
+    };
179
+    $arguments = func_get_args();
180
+    $curried = curryN($endsWith, 2);
181
+    return call_user_func_array($curried, $arguments);
182 182
 }
183 183
 
184 184
 /**
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
  */
189 189
 function filter()
190 190
 {
191
-  $filter = function (callable $predicateFunction, array $array) {
192
-     return array_values(array_filter($array, $predicateFunction));
193
-  };
194
-  $arguments = func_get_args();
195
-  $curried = curryN($filter, 2);
196
-  return call_user_func_array($curried, $arguments);
191
+    $filter = function (callable $predicateFunction, array $array) {
192
+        return array_values(array_filter($array, $predicateFunction));
193
+    };
194
+    $arguments = func_get_args();
195
+    $curried = curryN($filter, 2);
196
+    return call_user_func_array($curried, $arguments);
197 197
 }
198 198
 
199 199
 /**
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
  */
204 204
 function filterPreserveKey()
205 205
 {
206
-  $filter = function (callable $predicateFunction, array $array) {
206
+    $filter = function (callable $predicateFunction, array $array) {
207 207
     return array_filter($array, $predicateFunction);
208
-  };
209
-  $arguments = func_get_args();
210
-  $curried = curryN($filter, 2);
211
-  return call_user_func_array($curried, $arguments);
208
+    };
209
+    $arguments = func_get_args();
210
+    $curried = curryN($filter, 2);
211
+    return call_user_func_array($curried, $arguments);
212 212
 }
213 213
 
214 214
 /**
@@ -218,30 +218,30 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function find()
220 220
 {
221
-  $find = function (callable $predicateFunction, array $list) {
221
+    $find = function (callable $predicateFunction, array $list) {
222 222
     foreach ($list as $item) {
223
-      if ($predicateFunction($item)) {
223
+        if ($predicateFunction($item)) {
224 224
         return $item;
225
-      }
225
+        }
226 226
     }
227 227
     return null;
228
-  };
229
-  $arguments = func_get_args();
230
-  $curried = curryN($find, 2);
231
-  return call_user_func_array($curried, $arguments);
228
+    };
229
+    $arguments = func_get_args();
230
+    $curried = curryN($find, 2);
231
+    return call_user_func_array($curried, $arguments);
232 232
 }
233 233
 
234 234
 function first()
235 235
 {
236
-  $first = function (array $array) {
236
+    $first = function (array $array) {
237 237
     if (empty($array)) {
238
-      return null;
238
+        return null;
239 239
     }
240 240
     return $array[0];
241
-  };
242
-  $arguments = func_get_args();
243
-  $curried = curryN($first, 1);
244
-  return call_user_func_array($curried, $arguments);
241
+    };
242
+    $arguments = func_get_args();
243
+    $curried = curryN($first, 1);
244
+    return call_user_func_array($curried, $arguments);
245 245
 }
246 246
 
247 247
 /**
@@ -251,46 +251,46 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function groupBy()
253 253
 {
254
-  $groupBy = function (callable $keySelector, array $array) {
254
+    $groupBy = function (callable $keySelector, array $array) {
255 255
     return reduce(
256
-      function ($acc, $item) use ($keySelector) {
256
+        function ($acc, $item) use ($keySelector) {
257 257
         $key = $keySelector($item);
258 258
         $acc[$key] = is_array($acc[$key]) ? array_merge($acc[$key], [$item]) : [$item];
259 259
         return $acc;
260
-      },
261
-      [],
262
-      $array
260
+        },
261
+        [],
262
+        $array
263 263
     );
264
-  };
265
-  $arguments = func_get_args();
266
-  $curried = curryN($groupBy, 2);
267
-  return call_user_func_array($curried, $arguments);
264
+    };
265
+    $arguments = func_get_args();
266
+    $curried = curryN($groupBy, 2);
267
+    return call_user_func_array($curried, $arguments);
268 268
 }
269 269
 
270 270
 function head()
271 271
 {
272
-  $head = function (array $array) {
272
+    $head = function (array $array) {
273 273
     if (empty($array)) {
274
-      return null;
274
+        return null;
275 275
     }
276 276
     return $array[0];
277
-  };
278
-  $arguments = func_get_args();
279
-  $curried = curryN($head, 1);
280
-  return call_user_func_array($curried, $arguments);
277
+    };
278
+    $arguments = func_get_args();
279
+    $curried = curryN($head, 1);
280
+    return call_user_func_array($curried, $arguments);
281 281
 }
282 282
 
283 283
 function last()
284 284
 {
285
-  $last = function (array $array) {
285
+    $last = function (array $array) {
286 286
     if (empty($array)) {
287
-      return null;
287
+        return null;
288 288
     }
289 289
     return $array[count($array) - 1];
290
-  };
291
-  $arguments = func_get_args();
292
-  $curried = curryN($last, 1);
293
-  return call_user_func_array($curried, $arguments);
290
+    };
291
+    $arguments = func_get_args();
292
+    $curried = curryN($last, 1);
293
+    return call_user_func_array($curried, $arguments);
294 294
 }
295 295
 
296 296
 /**
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
  */
301 301
 function map()
302 302
 {
303
-  $arguments = func_get_args();
304
-  $curried = curryN('array_map', 2);
305
-  return call_user_func_array($curried, $arguments);
303
+    $arguments = func_get_args();
304
+    $curried = curryN('array_map', 2);
305
+    return call_user_func_array($curried, $arguments);
306 306
 }
307 307
 
308 308
 /**
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function prepend()
315 315
 {
316
-  $prepend = function ($item, array $array) {
316
+    $prepend = function ($item, array $array) {
317 317
     return array_merge([$item], $array);
318
-  };
319
-  $arguments = func_get_args();
320
-  $curriedAny = curryN($prepend, 2);
321
-  return call_user_func_array($curriedAny, $arguments);
318
+    };
319
+    $arguments = func_get_args();
320
+    $curriedAny = curryN($prepend, 2);
321
+    return call_user_func_array($curriedAny, $arguments);
322 322
 }
323 323
 
324 324
 /**
@@ -329,23 +329,23 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function reduce()
331 331
 {
332
-  $reduce = function (callable $accumulator, $initialValue, array $array) {
332
+    $reduce = function (callable $accumulator, $initialValue, array $array) {
333 333
     return array_reduce($array, $accumulator, $initialValue);
334
-  };
335
-  $arguments = func_get_args();
336
-  $curried = curryN($reduce, 3);
337
-  return call_user_func_array($curried, $arguments);
334
+    };
335
+    $arguments = func_get_args();
336
+    $curried = curryN($reduce, 3);
337
+    return call_user_func_array($curried, $arguments);
338 338
 }
339 339
 
340 340
 function tail()
341 341
 {
342
-  $tail = function (array $array) {
342
+    $tail = function (array $array) {
343 343
     if (empty($array)) {
344
-      return null;
344
+        return null;
345 345
     }
346 346
     return $array[count($array) - 1];
347
-  };
348
-  $arguments = func_get_args();
349
-  $curried = curryN($tail, 1);
350
-  return call_user_func_array($curried, $arguments);
347
+    };
348
+    $arguments = func_get_args();
349
+    $curried = curryN($tail, 1);
350
+    return call_user_func_array($curried, $arguments);
351 351
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function all()
10 10
 {
11
-  $all = function (callable $predicateFunction, array $array): bool {
11
+  $all = function(callable $predicateFunction, array $array): bool {
12 12
     if (empty($array)) {
13 13
       return false;
14 14
     }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function any()
33 33
 {
34
-  $any = function (callable $predicateFunction, array $array) {
34
+  $any = function(callable $predicateFunction, array $array) {
35 35
     if (empty($array)) {
36 36
       return false;
37 37
     }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function arrayForEach()
56 56
 {
57
-  $arrayForEach = function (callable $fn, array $array) {
57
+  $arrayForEach = function(callable $fn, array $array) {
58 58
     foreach ($array as $item) {
59 59
       $fn($item);
60 60
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function append()
74 74
 {
75
-  $append = function ($item, array $array) {
75
+  $append = function($item, array $array) {
76 76
     return array_merge($array, [$item]);
77 77
   };
78 78
   $arguments = func_get_args();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function concat()
90 90
 {
91
-  $concat = function (array $firstArray, array $secondArray) {
91
+  $concat = function(array $firstArray, array $secondArray) {
92 92
     return array_merge($firstArray, $secondArray);
93 93
   };
94 94
   $arguments = func_get_args();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function drop()
119 119
 {
120
-  $drop = function (int $index, array $array) {
120
+  $drop = function(int $index, array $array) {
121 121
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
122 122
   };
123 123
   $arguments = func_get_args();
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
  */
144 144
 function dropLast()
145 145
 {
146
-  $dropLast = function (array $array) {
147
-    $index = count($array)-1;
146
+  $dropLast = function(array $array) {
147
+    $index = count($array) - 1;
148 148
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
149 149
   };
150 150
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function endsWith()
162 162
 {
163
-  $endsWith = function ($suffix, $list) {
163
+  $endsWith = function($suffix, $list) {
164 164
     if (is_string($suffix) && is_string($list)) {
165 165
       return $suffix === '' || (($temp = strlen($list) - strlen($suffix)) >= 0 && strpos($list, $suffix) !== false);
166 166
     }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
       }
175 175
       return true;
176 176
     }
177
-    throw new \InvalidArgumentException(__FUNCTION__ . 'accepts only string or array as it arguments');
177
+    throw new \InvalidArgumentException(__FUNCTION__.'accepts only string or array as it arguments');
178 178
   };
179 179
   $arguments = func_get_args();
180 180
   $curried = curryN($endsWith, 2);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
  */
189 189
 function filter()
190 190
 {
191
-  $filter = function (callable $predicateFunction, array $array) {
191
+  $filter = function(callable $predicateFunction, array $array) {
192 192
      return array_values(array_filter($array, $predicateFunction));
193 193
   };
194 194
   $arguments = func_get_args();
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
  */
204 204
 function filterPreserveKey()
205 205
 {
206
-  $filter = function (callable $predicateFunction, array $array) {
206
+  $filter = function(callable $predicateFunction, array $array) {
207 207
     return array_filter($array, $predicateFunction);
208 208
   };
209 209
   $arguments = func_get_args();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function find()
220 220
 {
221
-  $find = function (callable $predicateFunction, array $list) {
221
+  $find = function(callable $predicateFunction, array $list) {
222 222
     foreach ($list as $item) {
223 223
       if ($predicateFunction($item)) {
224 224
         return $item;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 function first()
235 235
 {
236
-  $first = function (array $array) {
236
+  $first = function(array $array) {
237 237
     if (empty($array)) {
238 238
       return null;
239 239
     }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function groupBy()
253 253
 {
254
-  $groupBy = function (callable $keySelector, array $array) {
254
+  $groupBy = function(callable $keySelector, array $array) {
255 255
     return reduce(
256
-      function ($acc, $item) use ($keySelector) {
256
+      function($acc, $item) use ($keySelector) {
257 257
         $key = $keySelector($item);
258 258
         $acc[$key] = is_array($acc[$key]) ? array_merge($acc[$key], [$item]) : [$item];
259 259
         return $acc;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
 function head()
271 271
 {
272
-  $head = function (array $array) {
272
+  $head = function(array $array) {
273 273
     if (empty($array)) {
274 274
       return null;
275 275
     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 function last()
284 284
 {
285
-  $last = function (array $array) {
285
+  $last = function(array $array) {
286 286
     if (empty($array)) {
287 287
       return null;
288 288
     }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function prepend()
315 315
 {
316
-  $prepend = function ($item, array $array) {
316
+  $prepend = function($item, array $array) {
317 317
     return array_merge([$item], $array);
318 318
   };
319 319
   $arguments = func_get_args();
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function reduce()
331 331
 {
332
-  $reduce = function (callable $accumulator, $initialValue, array $array) {
332
+  $reduce = function(callable $accumulator, $initialValue, array $array) {
333 333
     return array_reduce($array, $accumulator, $initialValue);
334 334
   };
335 335
   $arguments = func_get_args();
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
 function tail()
341 341
 {
342
-  $tail = function (array $array) {
342
+  $tail = function(array $array) {
343 343
     if (empty($array)) {
344 344
       return null;
345 345
     }
Please login to merge, or discard this patch.