InternalPropertiesEmulationTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 29
ccs 4
cts 7
cp 0.5714
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
___debugInfo() 0 1 ?
A __get() 0 12 2
1
<?php
2
/**
3
 * Parser Reflection API
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\ParserReflection\Traits;
12
13
/**
14
 * Class for emulating internal properties behaviour
15
 */
16
trait InternalPropertiesEmulationTrait
17
{
18
    /**
19
     * Magic method that should be defined to provide an info about internal properties
20
     *
21
     * @return array
22
     */
23
    abstract public function ___debugInfo();
24
25
    /**
26
     * Magic implementation of properties
27
     *
28
     * @param string $propertyName Name of the property to return
29
     *
30
     * @return null|mixed
31
     */
32 54
    public function __get($propertyName)
33
    {
34 54
        $internalInfo = $this->___debugInfo();
35 54
        if (!isset($internalInfo[$propertyName])) {
36
            $className = get_class($this);
37
            trigger_error("Undefined property {$className}::\${$propertyName}");
38
39
            return null;
40
        }
41
42 54
        return $internalInfo[$propertyName];
43
    }
44
}
45