| Conditions | 6 |
| Paths | 32 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function configure(AbstractSeoGenerator $generator) |
||
| 19 | { |
||
| 20 | if (null !== $title = $this->getConfig('title')) { |
||
| 21 | $generator->setTitle($title); |
||
| 22 | } |
||
| 23 | if (null !== $description = $this->getConfig('description')) { |
||
| 24 | $generator->setDescription($description); |
||
| 25 | } |
||
| 26 | if (null !== $image = $this->getConfig('image')) { |
||
| 27 | $generator->setImage($image); |
||
|
|
|||
| 28 | } |
||
| 29 | if (null !== $card = $this->getConfig('card')) { |
||
| 30 | $generator->setCard($card); |
||
| 31 | } |
||
| 32 | if (null !== $site = $this->getConfig('site')) { |
||
| 33 | $generator->setSite($site); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
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: