| Conditions | 4 |
| Paths | 2 |
| Total Lines | 39 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | function compose() |
||
| 11 | { |
||
| 12 | |||
| 13 | static $g; |
||
|
|
|||
| 14 | if (! isset($g)) { |
||
| 15 | /** |
||
| 16 | * Apply function $f to $b iff $b is not null |
||
| 17 | * |
||
| 18 | * @param callable $f |
||
| 19 | * @param mixed $b |
||
| 20 | * |
||
| 21 | * @return mixed |
||
| 22 | */ |
||
| 23 | $g = function (callable $f, $b) { |
||
| 24 | return ( null === $b ) ? null : $f( $b ); |
||
| 25 | }; |
||
| 26 | }; |
||
| 27 | |||
| 28 | $fs = array_reverse(func_get_args()); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Apply a series of functions to $a |
||
| 32 | * |
||
| 33 | * @param mixed $a |
||
| 34 | * |
||
| 35 | * @return mixed |
||
| 36 | */ |
||
| 37 | return function ($a) use ($fs, $g) { |
||
| 38 | |||
| 39 | $b = $a; |
||
| 40 | foreach ($fs as $fn) { |
||
| 41 | $b = $g( $fn, $b ); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $b; |
||
| 45 | |||
| 46 | }; |
||
| 47 | |||
| 48 | } |
||
| 49 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.