Document::setProperty()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 3
1
<?php
2
3
namespace Saxulum\JsonDocument;
4
5
class Document
6
{
7
    /**
8
     * @return ObjectNodeBasedDocument
9
     */
10
    public static function createObjectNodeBased()
11
    {
12
        return new ObjectNodeBasedDocument();
13
    }
14
15
    /**
16
     * @return ArrayNodeBasedDocument
17
     */
18
    public static function createArrayNodeBased()
19
    {
20
        return new ArrayNodeBasedDocument();
21
    }
22
23
    /**
24
     * @param object $object
25
     * @param string $property
26
     * @param mixed  $value
27
     */
28
    public static function setProperty($object, $property, $value)
29
    {
30
        static $reflection;
31
32
        if (null === $reflection) {
33
            $reflection = new \ReflectionClass('Saxulum\JsonDocument\AbstractNode');
34
        }
35
36
        $pRef = $reflection->getProperty($property);
37
        $pRef->setAccessible(true);
38
        $pRef->setValue($object, $value);
39
        $pRef->setAccessible(false);
40
    }
41
}
42