Test Failed
Push — master ( 485f1a...210857 )
by Lucas
02:28
created

Extractor::extract()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 23
rs 8.5906
cc 5
eloc 13
nc 6
nop 2
1
<?php
2
3
namespace Silk\Exchange\Extractor;
4
5
use Silk\Configuration\PropertyConfiguration;
6
7
/**
8
 * Class Extractor
9
 * Responsável por executar a extração dos dados do objeto.
10
 * @author  Lucas A. de Araújo <[email protected]>
11
 * @package Silk\Exchange\Extractor
12
 */
13
class Extractor
14
{
15
    /**
16
     * Extrai as informações existentes em uma classe
17
     * @param $object
18
     * @return array
19
     */
20
    public static function extract($object, $parent = true)
21
    {
22
        $array = [];
23
24
        $class = (new \ReflectionClass($object))->getProperties();
25
26
        if($parent == false)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
27
            $class = (new \ReflectionClass($object))->getParentClass()->getProperties();
28
29
        foreach ($class as $property) {
30
            $config = new PropertyConfiguration($property, $object);
31
32
            if ($config->ignore() || $config->shouldIgnoreIfNull())
33
                continue;
34
35
            $name = $config->getAlias();
36
            $data = $config->getValue();
37
38
            $array[$name] = $data;
39
        }
40
41
        return $array;
42
    }
43
}