MethodAlias   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 25
ccs 7
cts 9
cp 0.7778
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 15 4
1
<?php
2
namespace Teto\Object;
3
4
/**
5
 * Make Property like method
6
 *
7
 * @author    USAMI Kenta <[email protected]>
8
 * @copyright 2016 Baguette HQ
9
 * @license   http://www.apache.org/licenses/LICENSE-2.0
10
 */
11
trait MethodAlias
12
{
13
    /**
14
     * Call alias method (magic method)
15
     *
16
     * @param  string $name
17
     * @return mixed
18
     * @see    http://php.net/manual/language.oop5.magic.php
19
     * @suppress PhanUndeclaredStaticProperty
20
     */
21 2
    public function __call($name, array $args)
22
    {
23 2
        if (!isset(self::$method_aliases)) {
24
            throw new \LogicException(static::class.'::$method_aliases is not set.');
25
        }
26
27 2
        if (isset(self::$method_aliases[$name])) {
28 1
            $method = self::$method_aliases[$name];
29 1
        } elseif (in_array($name, self::$method_aliases)) {
30
            $method = $name;
31
        } else {
32 1
            throw new \BadMethodCallException(static::class."::{$name}() is not exists.");
33
        }
34
35 1
        return call_user_func([$this, $method]);
36
    }
37
}
38