Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 2.5 |
Changes | 0 |
1 | <?php declare(strict_types = 1); |
||
48 | 1 | public function __doRequest($request, $location, $action, $version, $oneWay = 0) |
|
49 | { |
||
50 | 1 | $signedRequest = $this->cryptoService->addWSESignature($request); |
|
51 | 1 | $response = $this->clientDriver->send($signedRequest, $location, $action, $version); |
|
52 | |||
53 | if ($oneWay === 1) { |
||
54 | return null; |
||
55 | } |
||
56 | return $response; |
||
57 | } |
||
58 | |||
60 |
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 sub-classes 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 parent class: