| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 16 |
| Ratio | 100 % |
| Tests | 6 |
| CRAP Score | 3.1406 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 1 | View Code Duplication | public function getType($type) |
|
|
|||
| 28 | { |
||
| 29 | 1 | if (! $this->has($type)) { |
|
| 30 | 1 | $this->register($type); // auto-wiring (for Types with no special constructor dependencies) |
|
| 31 | } |
||
| 32 | |||
| 33 | 1 | $type = $this->get($type); |
|
| 34 | |||
| 35 | 1 | if (! $type instanceof Type) { |
|
| 36 | $class_name = get_class($type); |
||
| 37 | |||
| 38 | throw new UnexpectedValueException("{$class_name} does not implement the Type interface"); |
||
| 39 | } |
||
| 40 | |||
| 41 | 1 | return $type; |
|
| 42 | } |
||
| 43 | |||
| 52 |
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.