Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
25 | public function render(Menu $menu) |
||
26 | { |
||
27 | $output = '<ul>'; |
||
28 | |||
29 | foreach ($menu->items() as $item) { |
||
30 | if ($item instanceof Menu) { |
||
31 | // Have a new instance of this presenter render the nested/submenu item |
||
32 | $output .= sprintf('<li>%s%s</li>', $item->label, (new static)->render($item)); |
||
|
|||
33 | } else if ($item instanceof MenuItem) { |
||
34 | // Render the link as-is |
||
35 | $output .= sprintf( |
||
36 | '<li%1$s><a href="%2$s" title="%3$s">%3$s</a></li>', |
||
37 | $item->options('class') ? sprintf(' class="%s"', $item->options('class')) : null, |
||
38 | $item->link, |
||
39 | $item->label |
||
40 | ); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | $output .= '</ul>'; |
||
45 | |||
46 | return $output; |
||
47 | } |
||
48 | } |
||
49 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.