Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5.0144 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 81 | public static function normalize($definition, string $id = null): DefinitionInterface |
|
24 | { |
||
25 | 81 | if (is_array($definition) && isset($definition[DefinitionParser::IS_PREPARED_ARRAY_DEFINITION_DATA])) { |
|
26 | 34 | $class = $definition['class']; |
|
27 | 34 | $constructorArguments = $definition['__construct()']; |
|
28 | 34 | $methodsAndProperties = $definition['methodsAndProperties']; |
|
29 | |||
30 | 34 | $class = $class ?? $id; |
|
31 | 34 | if ($class === null) { |
|
32 | throw new InvalidConfigException('Invalid definition: don\'t set class name.'); |
||
33 | } |
||
34 | |||
35 | 34 | return ArrayDefinition::fromPreparedData($class, $constructorArguments, $methodsAndProperties); |
|
36 | } |
||
37 | |||
38 | 81 | if ($definition instanceof ExtensibleService) { |
|
39 | 3 | return $definition; |
|
40 | } |
||
41 | |||
42 | 81 | return Normalizer::normalize($definition, $id); |
|
43 | } |
||
45 |