Completed
Push — master ( afb851...604a2f )
by Anton
12s
created

ProxyTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 32
ccs 6
cts 7
cp 0.8571
rs 10
c 2
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setInstance() 0 4 1
A __callStatic() 0 7 2
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Proxy;
12
13
use Bluz\Common\Singleton;
14
15
/**
16
 * ProxyTrait
17
 *
18
 * @package  Bluz\Proxy
19
 * @author   Anton Shevchuk
20
 */
21
trait ProxyTrait
22
{
23
    use Singleton;
24
25
    /**
26
     * Set or replace instance
27
     *
28
     * @param  mixed $instance
29
     *
30
     * @return void
31
     */
32 633
    public static function setInstance($instance)
33
    {
34 633
        static::$instance = $instance;
35 633
    }
36
37
    /**
38
     * Handle dynamic, static calls to the object.
39
     *
40
     * @param  string $method
41
     * @param  array  $args
42
     *
43
     * @return mixed
44
     */
45 644
    public static function __callStatic($method, $args)
46
    {
47 644
        if ($instance = static::getInstance()) {
48 644
            return $instance->$method(...$args);
49
        }
50
        return false;
51
    }
52
}
53