Test Failed
Push — master ( 3eb0e4...9196b6 )
by Ivan
02:13
created

Property   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toObject() 0 13 2
A toArray() 0 6 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Everlution\Navigation\Factory\Build\Hydrator;
6
7
use Everlution\Navigation\Factory\Build\ClassDoesNotExistException;
8
use Everlution\Navigation\Factory\Build\Config;
9
use Everlution\Navigation\Factory\Build\PropertyConfig;
10
use Everlution\Navigation\Property\Property as PropertyObject;
11
12
/**
13
 * Class PropertyConfig.
14
 * @author Ivan Barlog <[email protected]>
15
 */
16
abstract class Property extends Config implements PropertyConfig
17
{
18
    /**
19
     * @param array $config
20
     * @return PropertyObject
21
     * @throws ClassDoesNotExistException
22
     */
23
    public function toObject(array $config): PropertyObject
24
    {
25
        $className = $this->popClassName($config);
26
        $this->checkIfSupport($className);
27
28
        $config = $this->resolve($config);
29
30
        if (false === class_exists($className)) {
31
            throw new ClassDoesNotExistException($className);
32
        }
33
34
        return $this->getObject($className, $config);
35
    }
36
37
    /**
38
     * @param PropertyObject $object
39
     * @return array
40
     */
41
    public function toArray(PropertyObject $object): array
42
    {
43
        $this->checkIfSupport(get_class($object));
44
45
        return $this->getArray($object);
46
    }
47
}
48