| Conditions | 2 |
| Paths | 5 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 43 | public function up(): void |
||
| 44 | { |
||
| 45 | try { |
||
| 46 | /** @var EmailQueueItem $proto */ |
||
| 47 | $proto = $this->modelFactory()->create(EmailQueueItem::class); |
||
| 48 | $table = $proto->source()->table(); |
||
|
|
|||
| 49 | |||
| 50 | $this->addFeedback( |
||
| 51 | "Updating <white>${table} Table</white>." |
||
| 52 | ); |
||
| 53 | |||
| 54 | $this->createOrAlter($proto); |
||
| 55 | } catch (PDOException $exception) { |
||
| 56 | $this->addError($exception->getMessage()); |
||
| 57 | $this->setStatus(self::FAILED_STATUS); |
||
| 58 | } |
||
| 59 | |||
| 60 | $this->setStatus(self::PROCESSED_STATUS); |
||
| 61 | } |
||
| 62 | |||
| 64 |
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: