| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 23 | public function __construct(Container $container) |
|
| 27 | { |
||
| 28 | 23 | parent::__construct($container); |
|
| 29 | |||
| 30 | 23 | $this->parameters = [ |
|
| 31 | 23 | 'title' => '', |
|
| 32 | 23 | 'url' => '#', |
|
| 33 | 23 | 'attributes' => $this->app->makeWith(Attributes::class, ['attributes' => []]), |
|
|
|
|||
| 34 | 23 | 'activeAttributes' => $this->app->makeWith(Attributes::class, ['attributes' => []]), |
|
| 35 | 23 | 'linkAttributes' => $this->app->makeWith(Attributes::class, ['attributes' => []]), |
|
| 36 | 23 | 'view' => $this->getElementConfig(Link::class)['view'], |
|
| 37 | 'displayRule' => true, |
||
| 38 | ]; |
||
| 39 | 23 | } |
|
| 40 | |||
| 52 | } |
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: