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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 6 1
B instantiate() 0 29 2
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