Completed
Push — master ( ab6687...f3fe24 )
by Woody
10s
created

Proxy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 47
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __clone() 0 4 1
A set() 0 5 1
A setArray() 0 7 2
A reveal() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\EntityProxy;
5
6
class Proxy
7
{
8
    /** @var object */
9
    private $instance;
10
11
    /** @var \ReflectionProperty[] */
12
    private $properties;
13
14
    /**
15
     * @param object $instance
16
     */
17 3
    public function __construct($instance, array $properties)
18
    {
19 3
        $this->instance = $instance;
20 3
        $this->properties = $properties;
21 3
    }
22
23 3
    public function __clone()
24
    {
25 3
        $this->instance = clone $this->instance;
26 3
    }
27
28
    /**
29
     * @param mixed $value
30
     */
31 2
    public function set(string $name, $value): self
32
    {
33 2
        $this->properties[$name]->setValue($this->instance, $value);
34 2
        return $this;
35
    }
36
37 1
    public function setArray(array $values): self
38
    {
39 1
        foreach ($values as $name => $value) {
40 1
            $this->set($name, $value);
41
        }
42 1
        return $this;
43
    }
44
45
    /**
46
     * @return object
47
     */
48 3
    public function reveal()
49
    {
50 3
        return $this->instance;
51
    }
52
}
53