NavbarRightPresenter::getMenuWithDropDownWrapper()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 4
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Menus\Presenters;
6
7
use Rinvex\Menus\Models\MenuItem;
8
9
class NavbarRightPresenter extends NavbarPresenter
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function getOpenTagWrapper(): string
15
    {
16
        return '<ul class="nav navbar-nav navbar-right">';
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getMenuWithDropDownWrapper(MenuItem $item, bool $specialSidebar = false): string
23
    {
24
        return $specialSidebar
25
            ? $this->getHeaderWrapper($item).$this->getChildMenuItems($item)
26
            : '<li class="dropdown pull-right">
27
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
28
                        '.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').'
0 ignored issues
show
Documentation introduced by
The property icon does not exist on object<Rinvex\Menus\Models\MenuItem>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read 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.

Loading history...
29
                        '.$item->title.'<strong class="caret"></strong>
0 ignored issues
show
Documentation introduced by
The property title does not exist on object<Rinvex\Menus\Models\MenuItem>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read 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.

Loading history...
30
                    </a>
31
                    <ul class="dropdown-menu">
32
                        '.$this->getChildMenuItems($item).'
33
                    </ul>
34
                </li>';
35
    }
36
}
37