Completed
Push — master ( f3fe24...8bf190 )
by Woody
9s
created

Proxy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 41
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

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