Issues (4)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Menu/Menu.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Roboc\Menu;
4
5
use Roboc\Support\Interfaces\MenuItemInterface;
6
7
/**
8
 * Class Menu
9
 * @package Roboc\Menu
10
 */
11
class Menu
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $identifier;
17
18
    /**
19
     * @var array
20
     */
21
    protected $items = [];
22
23
    /**
24
     * @var \Roboc\Support\Interfaces\MenuItemInterface
25
     */
26
    protected $parent;
27
28
    /**
29
     * Menu constructor.
30
     * @param string $identifier
31
     */
32
    public function __construct( $identifier )
33
    {
34
        $this->identifier = $identifier;
35
    }
36
37
    /**
38
     * @param MenuItemInterface $item
39
     * @return \Roboc\Support\Interfaces\MenuItemInterface
40
     */
41
    public function add( MenuItemInterface $item )
42
    {
43
        $this->items[] = $item;
44
45
        return $item;
46
    }
47
48
    /**
49
     * @param string $title
50
     * @return Item
51
     */
52
    public function item( $title )
53
    {
54
        return $this->add( new Item( $this ) )->title( $title );
55
    }
56
57
    /**
58
     * @return MenuItemInterface[]
59
     */
60
    public function items()
61
    {
62
        return $this->items;
63
    }
64
65
    /**
66
     * @return MenuItemInterface
67
     */
68
    public function parent()
69
    {
70
        return $this->parent;
71
    }
72
73
    /**
74
     * @return bool
75
     */
76
    public function hasParent()
77
    {
78
        return $this->parent !== null;
79
    }
80
81
    /**
82
     * @param $link
83
     * @return MenuItemInterface
0 ignored issues
show
Should the return type not be MenuItemInterface|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
84
     */
85
    public function getItemByLink( $link )
86
    {
87
        foreach( $this->items() as $item )
88
        {
89
            if( $item->getLink() === $link )
90
            {
91
                return $item;
92
            }
93
94
            if( $item->hasSubMenu() )
95
            {
96
                 $item = $item->getSubMenu()->getItemByLink( $link );
97
98
                if( $item )
99
                {
100
                    return $item;
101
                }
102
            }
103
        }
104
105
        return null;
106
    }
107
108
    /**
109
     * @param $link
110
     */
111
    public function setActive( $link )
112
    {
113
        $item = $this->getItemByLink( $link );
114
115
        if( $item )
116
        {
117
            $item->active( true );
118
        }
119
    }
120
121
    /**
122
     * @param MenuItemInterface $item
123
     */
124
    public function setParent( MenuItemInterface $item )
125
    {
126
        $this->parent = $item;
127
    }
128
129
    /**
130
     * @return bool
131
     */
132
    public function hasItems()
133
    {
134
        return (bool) count( $this->items );
135
    }
136
}
137