Accessor::setPropertyValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Er1z\FakeMock;
4
5
use Symfony\Component\PropertyAccess\PropertyAccess;
6
7
class Accessor
8
{
9
    /**
10
     * @var \Symfony\Component\PropertyAccess\PropertyAccessorInterface
11
     */
12
    protected static $accessor = null;
13
14 142
    protected static function getAccessor()
15
    {
16 142
        if (!self::$accessor) {
17 4
            self::$accessor = PropertyAccess::createPropertyAccessorBuilder()
18 4
                ->enableExceptionOnInvalidIndex()
19 4
                ->getPropertyAccessor();
20
        }
21
22 142
        return self::$accessor;
23
    }
24
25 42
    public static function setPropertyValue($obj, $prop, $val)
26
    {
27 42
        self::getAccessor()->setValue($obj, $prop, $val);
28 42
    }
29
30 135
    public static function getPropertyValue($obj, $prop)
31
    {
32 135
        return self::getAccessor()->getValue($obj, $prop);
33
    }
34
}
35