| 1 | <?php |
||
| 11 | class GetBVN extends AbstractPlugin |
||
| 12 | { |
||
| 13 | use VerifyHttpStatusResponseCode; |
||
| 14 | |||
| 15 | protected $baseUrl; |
||
| 16 | |||
| 17 | const GET_BVN_ENDPOINT = "/bank/resolve_bvn/:bvn"; |
||
| 18 | |||
| 19 | const VALID_BVN_LENGTH = 11; |
||
| 20 | |||
| 21 | 3 | public function __construct(string $baseUrl) |
|
| 25 | |||
| 26 | 3 | public function getPluginAccessor(): string |
|
| 30 | |||
| 31 | 3 | public function handle(string $bvn) |
|
| 53 | } |
||
| 54 |
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: