Completed
Push — master ( 934ce8...14a8a1 )
by Kirill
02:27
created

Properties   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 8
c 3
b 0
f 3
lcom 0
cbo 4
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C __debugInfo() 0 27 8
1
<?php
2
/**
3
 * This file is part of Properties package.
4
 *
5
 * @author Serafim <[email protected]>
6
 * @date 14.04.2016 17:07
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Serafim\Properties;
12
13
use Serafim\Properties\Support\Registry;
14
use Serafim\Properties\Support\Strings as Str;
15
16
/**
17
 * Class Properties
18
 * @package Serafim\Properties
19
 */
20
trait Properties
21
{
22
    use Getters, Setters;
23
24
25
26
27
    /**
28
     * @return array
29
     */
30
    public function __debugInfo()
31
    {
32
        $result = [];
33
        $reflection = new \ReflectionObject($this);
34
        $registry = Registry::get($this);
35
36
        foreach ($reflection->getProperties() as $property) {
37
            $name = $property->name;
38
            if ($property->isStatic()) {
39
                continue;
40
            }
41
42
            if ($property->isPublic()) {
43
                $result[$name] = $this->$name;
44
            }
45
46
            if ($property->isProtected() || $property->isPrivate()) {
47
                $property->setAccessible(true);
48
49
                if ($registry->has($name) && $registry->isReadable($name)) {
50
                    $result[$name] = $property->getValue($this);
51
                }
52
            }
53
        }
54
55
        return $result;
56
    }
57
}
58