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.

Link   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 69
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A to() 0 4 1
A text() 0 4 1
A render() 0 7 1
A __toString() 0 4 1
1
<?php
2
3
namespace Spatie\Menu;
4
5
use Spatie\Menu\Html\Attributes;
6
use Spatie\Menu\Traits\Activatable as ActivatableTrait;
7
use Spatie\Menu\Traits\Conditions as ConditionsTrait;
8
use Spatie\Menu\Traits\HasHtmlAttributes as HasHtmlAttributesTrait;
9
use Spatie\Menu\Traits\HasParentAttributes as HasParentAttributesTrait;
10
use Spatie\Menu\Traits\HasTextAttributes as HasAttributesTrait;
11
12
class Link implements Item, HasHtmlAttributes, HasParentAttributes, Activatable
13
{
14
    use ActivatableTrait, HasHtmlAttributesTrait, HasParentAttributesTrait, ConditionsTrait, HasAttributesTrait;
15
16
    /** @var string */
17
    protected $text;
18
19
    /** @var string|null */
20
    protected $url = null;
21
22
    /** @var string */
23
    protected $prepend, $append = '';
24
25
    /** @var bool */
26
    protected $active = false;
27
28
    /** @var \Spatie\Menu\Html\Attributes */
29
    protected $htmlAttributes, $parentAttributes;
30
31
    /**
32
     * @param string $url
33
     * @param string $text
34
     */
35
    protected function __construct(string $url, string $text)
36
    {
37
        $this->url = $url;
38
        $this->text = $text;
39
        $this->htmlAttributes = new Attributes();
40
        $this->parentAttributes = new Attributes();
41
    }
42
43
    /**
44
     * @param string $url
45
     * @param string $text
46
     *
47
     * @return static
48
     */
49
    public static function to(string $url, string $text)
50
    {
51
        return new static($url, $text);
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function text(): string
58
    {
59
        return $this->text;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function render(): string
66
    {
67
        $attributes = new Attributes(['href' => $this->url]);
68
        $attributes->mergeWith($this->htmlAttributes);
0 ignored issues
show
Documentation introduced by
$this->htmlAttributes is of type object<Spatie\Menu\Html\Attributes>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69
70
        return $this->prepend."<a {$attributes}>{$this->text}</a>".$this->append;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function __toString(): string
77
    {
78
        return $this->render();
79
    }
80
}
81