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

Proxy::setArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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