| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | trait CreateDefinitionsMethods |
||
| 20 | { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Creates the definition for registered data |
||
| 24 | * |
||
| 25 | * If value is a callable then the definition is Factory, otherwise |
||
| 26 | * it will create a Value definition. |
||
| 27 | * |
||
| 28 | * @param callable|mixed $value |
||
| 29 | * @param array $parameters |
||
| 30 | * |
||
| 31 | * @return Value|Alias|Factory |
||
| 32 | * @see Factory, Value |
||
| 33 | * |
||
| 34 | */ |
||
| 35 | protected function createDefinition( |
||
| 36 | mixed $value, |
||
| 37 | array $parameters = [] |
||
| 38 | ): Value|Alias|Factory { |
||
| 39 | if (is_callable($value)) { |
||
| 40 | return new Factory($value, $parameters); |
||
| 41 | } |
||
| 42 | return $this->createValueDefinition($value); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Creates a definition for provided name and value pair |
||
| 47 | * |
||
| 48 | * If $value is a string prefixed with '@' it will create an Alias |
||
| 49 | * definition. Otherwise, a Value definition will be created. |
||
| 50 | * |
||
| 51 | * @param mixed $value |
||
| 52 | * |
||
| 53 | * @return Value|Alias |
||
| 54 | */ |
||
| 55 | protected function createValueDefinition(mixed $value): Value|Alias |
||
| 62 | } |
||
| 63 | } |
||
| 64 |