| 1 | <?php |
||
| 10 | class ExportTransactions extends AbstractPlugin |
||
| 11 | { |
||
| 12 | |||
| 13 | use VerifyHttpStatusResponseCode; |
||
| 14 | |||
| 15 | const TRANSACTION_ENDPOINT = "/transaction/export"; |
||
| 16 | |||
| 17 | protected $baseUrl; |
||
| 18 | |||
| 19 | 2 | public function __construct(string $baseUrl) |
|
| 23 | |||
| 24 | 2 | public function getPluginAccessor(): string |
|
| 28 | |||
| 29 | 2 | public function handle(array $params = []) |
|
| 40 | |||
| 41 | 2 | protected function getExportedTransactions(string $link): ResponseInterface |
|
| 46 | } |
||
| 47 |
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: