Issues (10)

Security Analysis    not enabled

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/Menus/Item.php (2 issues)

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 Larabros\Laranav\Menus;
4
5
use Illuminate\Support\Collection;
6
7
class Item
8
{
9
    /**
10
     * The unique name used to identify an `Item` instance.
11
     *
12
     * @var string
13
     */
14
    protected $title;
15
16
    /**
17
     * The URL for the item.
18
     *
19
     * @var string
20
     */
21
    protected $url;
22
23
    /**
24
     * The active state of the item.
25
     *
26
     * @var bool
27
     */
28
    protected $isActive;
29
30
    /**
31
     * The CSS class used to highlight an active item.
32
     *
33
     * @var string
34
     */
35
    protected $activeClass;
36
37
    /**
38
     * A `Collection` of `Item` instances for any child items.
39
     *
40
     * @var Collection|null
41
     */
42
    protected $children;
43
44
    /**
45
     * The CSS class used to highlight an item with children.
46
     *
47
     * @var string
48
     */
49
    protected $childrenClass;
50
51
    /**
52
     * Create a new `Item` instance.
53
     *
54
     * @param string          $title
55
     * @param string          $url
56
     * @param boolean         $isActive
57
     * @param Collection|null $children
58
     * @param string          $activeClass
59
     * @param string          $childrenClass
60
     */
61 48
    public function __construct(
62
        $title,
63
        $url = '#',
64
        $isActive = false,
65
        Collection $children = null,
66
        $activeClass = 'active',
67
        $childrenClass = 'dropdown'
68
    ) {
69 48
        $this->title         = $title;
70 48
        $this->url           = $url;
71 48
        $this->isActive      = $isActive;
72 48
        $this->children      = $children;
73 48
        $this->activeClass   = $activeClass;
74 48
        $this->childrenClass = $childrenClass;
75 48
    }
76
77
    /**
78
     * Return title of the `Item` instance.
79
     *
80
     * @return string
81
     */
82 6
    public function getTitle()
83
    {
84 6
        return $this->title;
85
    }
86
87
    /**
88
     * Return the URL of the `Item` instance.
89
     *
90
     * @return string
91
     */
92 6
    public function getUrl()
93
    {
94 6
        return $this->url;
95
    }
96
97
    /**
98
     * Returns the active status of the item.
99
     *
100
     * @return boolean
101
     */
102 12
    public function isActive()
103
    {
104 12
        return $this->isActive;
105
    }
106
107
    /**
108
     * Check if this item has any children.
109
     *
110
     * @return boolean
111
     */
112 8
    public function hasChildren()
113
    {
114 8
        return (isset($this->children) && !is_null($this->children));
115
    }
116
117
    /**
118
     * Returns any child items as a `Collection`.
119
     *
120
     * @return Collection
121
     */
122 8
    public function getChildren()
123
    {
124 8
        return $this->hasChildren() ? $this->children : new Collection();
125
    }
126
127
    /**
128
     * Returns any CSS classes that should be applied to this item when, for
129
     * example highlighting an active link, or displaying a menu item with children.
130
     *
131
     * @return string
132
     */
133 16
    public function getClasses()
134
    {
135 16
        $classesString = '';
136
137
        // Check if this is the active item
138 16
        if ($this->isActive()) {
139 8
            $classesString .= "$this->activeClass ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
140 8
        }
141
142 16
        if ($this->hasChildren()) {
143 4
            $classesString .= "$this->childrenClass ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
144 4
        }
145
146 16
        return trim($classesString);
147
    }
148
}
149