AbstractProxy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 43
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A __call() 0 7 2
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\eCurring\Resource\Proxy;
6
7
use LauLamanApps\eCurring\eCurringClientInterface;
8
use LauLamanApps\eCurring\Resource\Subscription;
9
10
abstract class AbstractProxy
11
{
12
    /**
13
     * @var eCurringClientInterface
14
     */
15
    private $__client;
16
17
    /**
18
     * @var string
19
     */
20
    private $__id;
21
22
    /**
23
     * @var null|Subscription
24
     */
25
    private $__object;
26
27
    /**
28
     * @return SubscriptionProxy
29
     */
30 3
    public function __construct(eCurringClientInterface $client, $deviceId)
31
    {
32 3
        $this->__id = $deviceId;
33 3
        $this->__client = $client;
34 3
    }
35
36
    /**
37
     * @return Subscription
38
     */
39
    abstract protected function __load(eCurringClientInterface $client, string $id);
40
41 3
    public function getId()
42
    {
43 3
        return $this->__id;
44
    }
45
46
    public function __call($method, $args)
47
    {
48
        if (!$this->__object) {
49
            $this->__object = $this->__load($this->__client, $this->__id);
50
        }
51
52
        return call_user_func_array([$this->__object, $method], $args);
53
    }
54
}
55