Extractor   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B extract() 0 23 5
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
}