| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 14 |
| Ratio | 100 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 52 | 10 | View Code Duplication | private function warnForUnvaluedVariables(Hydrator $processor): void |
| 53 | { |
||
| 54 | 10 | $unvaluedVariables = $processor->getUnvaluedVariables(); |
|
| 55 | |||
| 56 | 10 | if(! empty($unvaluedVariables)) |
|
| 57 | { |
||
| 58 | 1 | $logger = $this->app['logger']; |
|
| 59 | |||
| 60 | 1 | $logger->warning(sprintf( |
|
| 61 | 1 | 'Missing values for variables : %s (TODO markers found)', |
|
| 62 | 1 | implode(', ', $unvaluedVariables) |
|
| 63 | )); |
||
| 64 | } |
||
| 65 | 10 | } |
|
| 66 | } |
||
| 67 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: