| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 16 |
| Ratio | 100 % |
| Tests | 6 |
| CRAP Score | 3.1406 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 41 | 1 | View Code Duplication | public function getSchema($schema) |
|
|
|||
| 42 | { |
||
| 43 | 1 | if (! $this->container->has($schema)) { |
|
| 44 | 1 | $this->container->register($schema); // auto-wiring (for Schema with no special constructor dependencies) |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | $schema = $this->container->get($schema); |
|
| 48 | |||
| 49 | 1 | if (! $schema instanceof Schema) { |
|
| 50 | $class_name = get_class($schema); |
||
| 51 | |||
| 52 | throw new UnexpectedValueException("{$class_name} does not extend the Schema class"); |
||
| 53 | } |
||
| 54 | |||
| 55 | 1 | return $schema; |
|
| 56 | } |
||
| 57 | |||
| 68 |
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.