GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HasHtmlAttributes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 39
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setAttribute() 0 6 1
A setAttributes() 0 6 1
A addClass() 0 6 1
1
<?php
2
3
namespace Spatie\Menu\Traits;
4
5
/**
6
 * Expects a `$htmlAttributes` propert on the class.
7
 *
8
 * @property $htmlAttributes \Spatie\Menu\Html\Attributes
9
 */
10
trait HasHtmlAttributes
11
{
12
    /**
13
     * @param string $attribute
14
     * @param string $value
15
     *
16
     * @return $this
17
     */
18
    public function setAttribute(string $attribute, string $value = '')
19
    {
20
        $this->htmlAttributes->setAttribute($attribute, $value);
0 ignored issues
show
Bug introduced by
The property htmlAttributes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
22
        return $this;
23
    }
24
25
    /**
26
     * @param array $attributes
27
     *
28
     * @return $this
29
     */
30
    public function setAttributes(array $attributes)
31
    {
32
        $this->htmlAttributes->setAttributes($attributes);
33
34
        return $this;
35
    }
36
37
    /**
38
     * @param string $class
39
     *
40
     * @return $this
41
     */
42
    public function addClass(string $class)
43
    {
44
        $this->htmlAttributes->addClass($class);
45
46
        return $this;
47
    }
48
}
49