Completed
Push — master ( ec917c...cb6b70 )
by Nikola
04:17
created

ReflectiveAbstractBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureParameters() 0 13 3
1
<?php
2
/*
3
 * This file is part of the Abstract builder package, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\AbstractBuilder;
11
12
/**
13
 * Class ReflectiveAbstractBuilder
14
 *
15
 * Reflective abstract builder uses reflections to determine constructor parameters.
16
 *
17
 * @package RunOpenCode\AbstractBuilder
18
 */
19
abstract class ReflectiveAbstractBuilder extends AbstractBuilder
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    protected function configureParameters()
25
    {
26 1
        $parameters = [];
27
28 1
        $reflectionClass = new \ReflectionClass($this->getObjectFqcn());
29 1
        $constructor = $reflectionClass->getConstructor();
30
31 1
        foreach ($constructor->getParameters() as $reflectionParameter) {
32 1
            $parameters[$reflectionParameter->getName()] = ($reflectionParameter->isDefaultValueAvailable()) ? $reflectionParameter->getDefaultValue() : null;
33
        }
34
35 1
        return $parameters;
36
    }
37
}
38