| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 15 | public function render(RenderInterface $renderer, QueryInterface $query, $object) |
||
| 16 | { |
||
| 17 | // Get all available groups from db |
||
| 18 | $groupSelect = array(); |
||
| 19 | foreach ($query->className('group')->cond('Active', 1)->exec() as $group) { |
||
|
|
|||
| 20 | $groupSelect[] = $group->GroupID.':'.$group->Name; |
||
| 21 | } |
||
| 22 | |||
| 23 | // Set view |
||
| 24 | return $renderer->view($this->innerView) |
||
| 25 | ->set($this->css, 'class') |
||
| 26 | ->set($this->title, 'title') |
||
| 27 | ->set($object, 'item') |
||
| 28 | ->set( |
||
| 29 | m('samsoncms_input_application')->createFieldByType( |
||
| 30 | $query, |
||
| 31 | 4, |
||
| 32 | $object, |
||
| 33 | $this->name |
||
| 34 | )->build(implode(',', $groupSelect)), |
||
| 35 | 'field' |
||
| 36 | )->output(); |
||
| 37 | } |
||
| 38 | } |
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: