Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Lines | 16 |
Ratio | 100 % |
Tests | 9 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
35 | 10 | View Code Duplication | private function warnForUnusedVariables(Hydrator $processor) |
36 | { |
||
37 | 10 | $unusedVariables = $processor->getUnusedVariables(); |
|
38 | |||
39 | 10 | if(! empty($unusedVariables)) |
|
40 | { |
||
41 | 8 | $logger = $this->app['logger']; |
|
42 | |||
43 | 8 | $logger->warning('You have unused variables : you should remove them or check if you have not mispelled them'); |
|
44 | |||
45 | 8 | $logger->warning(sprintf( |
|
46 | 8 | 'Unused variables : %s', |
|
47 | 8 | implode(', ', $unusedVariables) |
|
48 | )); |
||
49 | } |
||
50 | 10 | } |
|
51 | |||
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: