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.

HasParentAttributes::setParentAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Menu\Traits;
4
5
/**
6
 * Expects a `$parentAttributes` propert on the class.
7
 *
8
 * @property $parentAttributes \Spatie\Menu\Html\Attributes
9
 */
10
trait HasParentAttributes
11
{
12
    /**
13
     * Return an array of attributes to apply on the parent. This generally means
14
     * the attributes that should be applied on the <li> tag.
15
     *
16
     * @return array
17
     */
18
    public function parentAttributes(): array
19
    {
20
        return $this->parentAttributes->toArray();
0 ignored issues
show
Bug introduced by
The property parentAttributes 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
23
    /**
24
     * @param string $attribute
25
     * @param string $value
26
     *
27
     * @return $this
28
     */
29
    public function setParentAttribute(string $attribute, string $value = '')
30
    {
31
        $this->parentAttributes->setAttribute($attribute, $value);
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param array $attributes
38
     *
39
     * @return $this
40
     */
41
    public function setParentAttributes(array $attributes)
42
    {
43
        $this->parentAttributes->setAttributes($attributes);
44
45
        return $this;
46
    }
47
48
    /**
49
     * @param string $class
50
     *
51
     * @return $this
52
     */
53
    public function addParentClass(string $class)
54
    {
55
        $this->parentAttributes->addClass($class);
56
57
        return $this;
58
    }
59
}
60