Completed
Push — master ( 44cd2c...638a5b )
by Daniel
05:15
created

StaticArr   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 1 Features 2
Metric Value
wmc 3
c 4
b 1
f 2
lcom 0
cbo 1
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 16 3
1
<?php
2
namespace Narrowspark\Arr;
3
4
use BadMethodCallException;
5
6
/**
7
 * Class StaticArr
8
 */
9
class StaticArr
10
{
11
    /**
12
     * Creates an instance of Arr and invokes the given method with the
13
     * rest of the passed arguments.
14
     * The result is not cast, so the return value may be of type Arr, array,
15
     * integer, boolean, etc.
16
     *
17
     * @param string  $name
18
     * @param mixed[] $arguments
19
     *
20
     * @throws \BadMethodCallException
21
     *
22
     * @return mixed
23
     */
24
    public static function __callStatic($name, $arguments)
25
    {
26
        if (!isset(static::$methodArgs[$name])) {
27
            throw new BadMethodCallException($name . ' is not a valid method');
28
        }
29
30
        $numArgs = count($arguments);
31
32
        if ($numArgs === static::$methodArgs[$name]) {
33
            $args = array_slice($arguments, 1, -1);
34
        } else {
35
            $args = array_slice($arguments, 1);
36
        }
37
38
        return call_user_func_array([new Arr(), $name], $args);
39
    }
40
}
41