| Conditions | 1 |
| Paths | 1 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 6 | public function __construct(Container $container) |
|
| 19 | { |
||
| 20 | 6 | parent::__construct($container); |
|
| 21 | |||
| 22 | 6 | $this->parameters['builder'] = $this->app->makeWith(Builder::class, [ |
|
|
|
|||
| 23 | 6 | 'container' => $this->app, |
|
| 24 | 6 | 'name' => 'submenu-' . spl_object_hash($this), |
|
| 25 | 6 | 'activeAttributes' => $this->app->makeWith(Attributes::class, ['attributes' => []]), |
|
| 26 | 6 | 'attributes' => $this->app->makeWith(Attributes::class, ['attributes' => []]), |
|
| 27 | ]); |
||
| 28 | 6 | $this->parameters['view'] = $this->getElementConfig(SubMenu::class)['view']; |
|
| 29 | 6 | } |
|
| 30 | |||
| 42 | } |
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: