Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | protected function doValidation(ResponseInterface $response) |
||
28 | { |
||
29 | if (strpos((string) $response->getUri(), 'favicon.ico') === false) { |
||
|
|||
30 | return; |
||
31 | } |
||
32 | |||
33 | $imageHash = md5((string)$response->getBody()); |
||
34 | |||
35 | $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework (' . $this->favicons[$imageHash] . ').'); |
||
36 | } |
||
37 | } |
||
38 |
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: