Completed
Push — master ( d0a683...32c794 )
by Sebastian
05:48
created

Link::toAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 4
1
<?php
2
3
namespace Spatie\Menu\Laravel;
4
5
use Illuminate\Support\Traits\Macroable;
6
use Spatie\Menu\Link as BaseLink;
7
8
class Link extends BaseLink
9
{
10
    use Macroable;
11
12
    /**
13
     * @param string $path
14
     * @param string $text
15
     * @param array $parameters
16
     * @param bool|null $secure
17
     *
18
     * @return static
19
     */
20
    public static function toUrl(string $path, string $text, array $parameters = [], $secure = null)
21
    {
22
        return static::to(url($path, $parameters, $secure), $text);
0 ignored issues
show
Bug introduced by
It seems like url($path, $parameters, $secure) targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; however, Spatie\Menu\Link::to() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
23
    }
24
25
    /**
26
     * @param string $action
27
     * @param string $text
28
     * @param array $parameters
29
     * @param bool $absolute
30
     *
31
     * @return static
32
     */
33
    public static function toAction(string $action, string $text, array $parameters = [], bool $absolute = true)
34
    {
35
        return static::to(action($action, $parameters, $absolute), $text);
36
    }
37
38
    /**
39
     * @param string $name
40
     * @param string $text
41
     * @param array $parameters
42
     * @param bool $absolute
43
     * @param \Illuminate\Routing\Route|null $route
44
     *
45
     * @return static
46
     */
47
    public static function toRoute(string $name, string $text, array $parameters = [], $absolute = true, $route = null)
48
    {
49
        return static::to(route($name, $parameters, $absolute, $route), $text);
0 ignored issues
show
Unused Code introduced by
The call to route() has too many arguments starting with $route.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
50
    }
51
}
52