| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class ReferenceDefinition implements Definition, Shareable, CallableMethod, Taggable |
||
| 18 | { |
||
| 19 | use IdentifiableTrait; |
||
| 20 | use ShareableTrait; |
||
| 21 | use CallableMethodTrait; |
||
| 22 | use TaggableTrait; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $id; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Closure |
||
| 31 | */ |
||
| 32 | protected $fn; |
||
| 33 | |||
| 34 | public function __construct(string $id, Closure $fn = null) |
||
| 35 | { |
||
| 36 | $this->id = $id; |
||
| 37 | $this->fn = $fn; |
||
| 38 | |||
| 39 | if (! $this->fn instanceof Closure) { |
||
| 40 | $this->fn = function ($instance, ContainerInterface $c) { |
||
|
|
|||
| 41 | return $instance; |
||
| 42 | }; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | public function id(): string |
||
| 47 | { |
||
| 48 | return $this->id; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getConcrete(ContainerInterface $container) |
||
| 52 | { |
||
| 53 | return ($this->fn)($container->get($this->id), $container); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function __toString(): string |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.