Completed
Push — master ( d55531...cfe428 )
by Amine
02:42
created
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/functions.php 2 patches
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function _number_of_args($fn) {
17 17
     $reflector = is_array($fn) ?
18
-        new \ReflectionMethod($fn[0], $fn[1]) :
19
-        new \ReflectionFunction($fn);
18
+        new \ReflectionMethod($fn[0], $fn[1]) : new \ReflectionFunction($fn);
20 19
     return $reflector->getNumberOfParameters();
21 20
 }
22 21
 
@@ -55,11 +54,11 @@  discard block
 block discarded – undo
55 54
             $i = 0; // index in $args
56 55
             $k = 0; // index in rest
57 56
             $restCount = $allArgsCount - $fnArgsCount;
58
-            while($placeholdersCount > 0 && $k < $restCount) {
57
+            while ($placeholdersCount > 0 && $k < $restCount) {
59 58
                 $arg = $rest[$k];
60
-                while(! _is_placeholder($args[$i]))
61
-                    $i++;
62
-                if (! _is_placeholder($arg)) {
59
+                while (!_is_placeholder($args[$i]))
60
+                    $i ++;
61
+                if (!_is_placeholder($arg)) {
63 62
                     $args[$i] = $arg;
64 63
                     $placeholdersCount --;
65 64
                 }
@@ -185,9 +184,9 @@  discard block
 block discarded – undo
185 184
  */
186 185
 function pipe() {
187 186
     $fns = func_get_args();
188
-    if(count($fns) < 1)
187
+    if (count($fns) < 1)
189 188
         throw new InvalidArgument("pipe() requires at least one argument");
190
-    return curry(function () use ($fns) {
189
+    return curry(function() use ($fns) {
191 190
         $result = _apply(array_shift($fns), func_get_args());
192 191
         foreach ($fns as $fn) {
193 192
             $result = $fn($result);
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,8 +57,9 @@  discard block
 block discarded – undo
57 57
             $restCount = $allArgsCount - $fnArgsCount;
58 58
             while($placeholdersCount > 0 && $k < $restCount) {
59 59
                 $arg = $rest[$k];
60
-                while(! _is_placeholder($args[$i]))
61
-                    $i++;
60
+                while(! _is_placeholder($args[$i])) {
61
+                                    $i++;
62
+                }
62 63
                 if (! _is_placeholder($arg)) {
63 64
                     $args[$i] = $arg;
64 65
                     $placeholdersCount --;
@@ -93,8 +94,9 @@  discard block
 block discarded – undo
93 94
 function _curried_function($fn, $argsCount, $boundArgs = []) {
94 95
     return function() use($fn, $argsCount, $boundArgs) {
95 96
         $merged = _merge_args($argsCount, $boundArgs, func_get_args());
96
-        if ($merged['count'] >= $argsCount)
97
-            return call_user_func_array($fn, $merged['args']);
97
+        if ($merged['count'] >= $argsCount) {
98
+                    return call_user_func_array($fn, $merged['args']);
99
+        }
98 100
         return _curried_function($fn, $argsCount, $merged['args']);
99 101
     };
100 102
 }
@@ -185,8 +187,9 @@  discard block
 block discarded – undo
185 187
  */
186 188
 function pipe() {
187 189
     $fns = func_get_args();
188
-    if(count($fns) < 1)
189
-        throw new InvalidArgument("pipe() requires at least one argument");
190
+    if(count($fns) < 1) {
191
+            throw new InvalidArgument("pipe() requires at least one argument");
192
+    }
190 193
     return curry(function () use ($fns) {
191 194
         $result = _apply(array_shift($fns), func_get_args());
192 195
         foreach ($fns as $fn) {
Please login to merge, or discard this patch.
src/Placeholder.php 2 patches
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.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@
 block discarded – undo
11 11
     private function __construct(){}
12 12
     public static function get()
13 13
     {
14
-        if(static::$instance === null)
15
-            static::$instance = new Placeholder;
14
+        if(static::$instance === null) {
15
+                    static::$instance = new Placeholder;
16
+        }
16 17
         return static::$instance;
17 18
     }
18 19
     public function __toString(){
Please login to merge, or discard this patch.
try.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 function numberOfArgs($fn) {
4 4
     $reflector = is_array($fn) ?
5
-        new ReflectionMethod($fn[0], $fn[1]) :
6
-        new ReflectionFunction($fn);
5
+        new ReflectionMethod($fn[0], $fn[1]) : new ReflectionFunction($fn);
7 6
     return $reflector->getNumberOfParameters();
8 7
 }
9 8
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 function curriedFunction($fn, $argsCount, $boundArgs = []) {
15 15
     return function() use($fn, $argsCount, $boundArgs) {
16 16
         $boundArgs = array_merge($boundArgs, func_get_args());
17
-        if (count($boundArgs) >= $argsCount)
18
-            return call_user_func_array($fn, $boundArgs);
17
+        if (count($boundArgs) >= $argsCount) {
18
+                    return call_user_func_array($fn, $boundArgs);
19
+        }
19 20
         return curriedFunction($fn, $argsCount, $boundArgs);
20 21
     };
21 22
 }
Please login to merge, or discard this patch.