GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractProxy::instantiate()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 29
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 2
nop 2
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Gandung\JWT\Proxy;
4
5
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
6
7
/**
8
 * @author Paulus Gandung Prakosa <[email protected]>
9
 */
10
abstract class AbstractProxy
11
{
12
    /**
13
     * @var LazyLoadingValueHolderFactory
14
     */
15
    private $proxy;
16
17
    public function __construct(LazyLoadingValueHolderFactory $proxy)
18
    {
19
        $this->proxy = $proxy;
20
    }
21
22
    /**
23
     * For chainability purpose.
24
     */
25
    public static function create()
26
    {
27
        return new static(
28
            new LazyLoadingValueHolderFactory()
29
        );
30
    }
31
32
    /**
33
     * Create virtual proxy from given class name and constructor arguments.
34
     *
35
     * @param string $class
36
     * @param array $constructorArg
37
     * @return object
38
     */
39
    protected function instantiate($class, $constructorArg = [])
40
    {
41
        if (!class_exists($class)) {
42
            throw new \InvalidArgumentException(
43
                sprintf("Class '%s' not exists.", $class)
44
            );
45
        }
46
47
        $proxy = $this->proxy->createProxy(
48
            $class,
49
            function (
50
                &$wrappedObject,
51
                $proxy,
52
                $method,
53
                $parameters,
54
                &$initializer
55
            ) use (
56
                $class,
57
                $constructorArg
58
) {
59
                $wrappedObject = (new \ReflectionClass($class))->newInstanceArgs($constructorArg);
60
                $initializer = null;
61
62
                return true;
63
            }
64
        );
65
66
        return $proxy;
67
    }
68
}
69