Passed
Branch master (17e5cc)
by Gaetano
01:47
created

Prototypeable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 5
c 2
b 1
f 1
dl 0
loc 40
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addMethod() 0 3 1
A __call() 0 3 1
A __callStatic() 0 3 1
A addStaticMethod() 0 3 1
1
<?php
2
3
namespace skrtdev\Prototypes;
4
5
use Closure;
6
7
trait Prototypeable{
8
9
    /**
10
     * @param string $name
11
     * @param array $args
12
     * @return mixed
13
     */
14
    public function __call(string $name, array $args)
15
    {
16
        return Prototypes::call($this, $name, $args);
17
    }
18
19
    /**
20
     * @param string $name
21
     * @param Closure $fun
22
     * @throws Exception
23
     */
24
    final public static function addMethod(string $name, Closure $fun): void
25
    {
26
        Prototypes::addClassMethod(static::class, $name, $fun);
27
    }
28
29
    /**
30
     * @param string $name
31
     * @param array $args
32
     * @return mixed
33
     */
34
    public static function __callStatic(string $name, array $args)
35
    {
36
        return Prototypes::callStatic(static::class, $name, $args);
37
    }
38
39
    /**
40
     * @param string $name
41
     * @param Closure $fun
42
     * @throws Exception
43
     */
44
    final public static function addStaticMethod(string $name, Closure $fun): void
45
    {
46
        Prototypes::addClassStaticMethod(static::class, $name, $fun);
47
    }
48
}
49
50