Extractor::extract()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 10
nc 3
nop 1
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)
21
    {
22
        $array = [];
23
24
        foreach ((new \ReflectionClass($object))->getProperties() as $property) {
25
            $config = new PropertyConfiguration($property, $object);
26
27
            if ($config->ignore() || $config->shouldIgnoreIfNull())
28
                continue;
29
30
            $name = $config->getAlias();
31
            $data = $config->getValue();
32
33
            $array[$name] = $data;
34
        }
35
36
        return $array;
37
    }
38
}