This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace Modules\Menu\Composers; |
||
2 | |||
3 | use Modules\Menu\Entities\Menuitem as MenuitemEntity; |
||
4 | use Modules\Menu\Repositories\MenuItemRepository; |
||
5 | use Modules\Menu\Repositories\MenuRepository; |
||
6 | use Pingpong\Menus\Builder; |
||
7 | use Pingpong\Menus\Facades\Menu; |
||
8 | use Pingpong\Menus\MenuItem; |
||
9 | |||
10 | class NavigationViewComposer |
||
11 | { |
||
12 | /** |
||
13 | * @var MenuRepository |
||
14 | */ |
||
15 | private $menu; |
||
16 | /** |
||
17 | * @var MenuItemRepository |
||
18 | */ |
||
19 | private $menuItem; |
||
20 | |||
21 | public function __construct(MenuRepository $menu, MenuItemRepository $menuItem) |
||
22 | { |
||
23 | $this->menu = $menu; |
||
24 | $this->menuItem = $menuItem; |
||
25 | } |
||
26 | |||
27 | public function compose() |
||
28 | { |
||
29 | foreach ($this->menu->all() as $menu) { |
||
30 | $menuTree = $this->menuItem->getTreeForMenu($menu->id); |
||
31 | Menu::create($menu->name, function (Builder $menu) use ($menuTree) { |
||
32 | foreach ($menuTree as $menuItem) { |
||
33 | $this->addItemToMenu($menuItem, $menu); |
||
34 | } |
||
35 | }); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Add a menu item to the menu |
||
41 | * @param MenuitemEntity $item |
||
42 | * @param Builder $menu |
||
43 | */ |
||
44 | View Code Duplication | public function addItemToMenu(MenuitemEntity $item, Builder $menu) |
|
0 ignored issues
–
show
|
|||
45 | { |
||
46 | if ($this->hasChildren($item)) { |
||
47 | $this->addChildrenToMenu($item->title, $item->items, $menu); |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() The property
items does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
48 | } else { |
||
49 | $target = $item->uri ?: $item->url; |
||
0 ignored issues
–
show
The property
uri does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() The property
url does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
50 | $menu->url( |
||
51 | $target, |
||
52 | $item->title, |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
53 | ['target' => $item->target] |
||
0 ignored issues
–
show
The property
target does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
54 | ); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Add children to menu under the give name |
||
60 | * |
||
61 | * @param string $name |
||
62 | * @param object $children |
||
63 | * @param Builder|MenuItem $menu |
||
64 | */ |
||
65 | private function addChildrenToMenu($name, $children, $menu) |
||
66 | { |
||
67 | $menu->dropdown($name, function (MenuItem $subMenu) use ($children) { |
||
68 | foreach ($children as $child) { |
||
69 | $this->addSubItemToMenu($child, $subMenu); |
||
70 | } |
||
71 | }); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Add children to the given menu recursively |
||
76 | * |
||
77 | * @param MenuitemEntity $child |
||
78 | * @param MenuItem $sub |
||
79 | */ |
||
80 | private function addSubItemToMenu(MenuitemEntity $child, MenuItem $sub) |
||
81 | { |
||
82 | $sub->url($child->uri, $child->title); |
||
0 ignored issues
–
show
The property
uri does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
83 | |||
84 | if ($this->hasChildren($child)) { |
||
85 | $this->addChildrenToMenu($child->title, $child->items, $sub); |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() The property
items does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
86 | } |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Check if the given menu item has children |
||
91 | * |
||
92 | * @param object $item |
||
93 | * @return bool |
||
94 | */ |
||
95 | private function hasChildren($item) |
||
96 | { |
||
97 | return $item->items->count() > 0; |
||
98 | } |
||
99 | } |
||
100 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.