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

Proxy::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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