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

ReflectiveAbstractBuilder::configureParameters()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
crap 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