1 | <?php |
||
10 | class DeactivateAuthorization extends AbstractPlugin |
||
11 | { |
||
12 | use VerifyHttpStatusResponseCode; |
||
13 | |||
14 | const DEACTIVATE_AUTHORIZATION_ENDPOINT = "/customer/deactivate_authorization"; |
||
15 | |||
16 | protected $baseUrl; |
||
17 | |||
18 | 2 | public function __construct(string $baseUrl) |
|
22 | |||
23 | 2 | public function getPluginAccessor(): string |
|
27 | |||
28 | 2 | public function handle(string $authorizationCode) |
|
41 | } |
||
42 |
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: