Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Lines | 16 |
Ratio | 100 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
31 | 13 | public function resolve($ref): MiddlewareInterface |
|
32 | { |
||
33 | 13 | if ($ref instanceof MiddlewareInterface) { |
|
34 | 7 | return $ref; |
|
35 | } |
||
36 | |||
37 | 12 | if (is_callable($ref)) { |
|
38 | 7 | return new CallableMiddleware($ref); |
|
39 | } |
||
40 | |||
41 | 11 | if (!is_string($ref)) { |
|
42 | 1 | throw new \InvalidArgumentException('Argument 1 $ref must be one of an instance of MiddlewareInterface, a callable or string.'); |
|
43 | } |
||
44 | |||
45 | 10 | return $this->resolveByContainer($ref, $this->container, MiddlewareInterface::class); |
|
46 | } |
||
47 | } |
||
48 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.