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.
Passed
Branch development (184ec4)
by butschster
06:08
created

Breadcrumbs::renderIfExistsArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SleepingOwl\Admin\Templates;
4
5
use DaveJamesMiller\Breadcrumbs\Manager as BreadcrumbsManager;
6
use SleepingOwl\Admin\Contracts\Template\Breadcrumbs as BreadcrumbsContract;
7
8
class Breadcrumbs extends BreadcrumbsManager implements BreadcrumbsContract
9
{
10
    /**
11
     * @param string|null $name
12
     *
13
     * @return string
14
     */
15
    public function render($name = null)
16
    {
17
        if (is_null($name)) {
18
            list($name, $params) = $this->currentRoute->get();
19
        } else {
20
            $params = array_slice(func_get_args(), 1);
21
        }
22
23
        return $this->view($this->generator->generate($this->callbacks, $name, $params));
24
    }
25
26
    /**
27
     * @param string|null $name
28
     *
29
     * @return string
30
     */
31
    public function renderIfExists($name = null)
32
    {
33
        if (is_null($name)) {
34
            list($name, $params) = $this->currentRoute->get();
0 ignored issues
show
Unused Code introduced by
The assignment to $params is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
35
        }
36
37
        if (! $this->exists($name)) {
38
            return '';
39
        }
40
41
        return $this->render($name);
42
    }
43
44
    /**
45
     * @param string $name
46
     * @param array $params
47
     *
48
     * @return string
49
     */
50
    public function renderArray($name, $params = [])
51
    {
52
        return $this->view($this->generator->generate($this->callbacks, $name, $params));
53
    }
54
55
    /**
56
     * @param string $name
57
     * @param array $params
58
     *
59
     * @return string
60
     */
61
    public function renderIfExistsArray($name, $params = [])
62
    {
63
        if (! $this->exists($name)) {
64
            return '';
65
        }
66
67
        return $this->renderArray($name, $params);
68
    }
69
70
    /**
71
     * @param array $breadcrumbs
72
     *
73
     * @return string
74
     */
75
    protected function view(array $breadcrumbs)
76
    {
77
        return $this->view->render($this->viewName, $breadcrumbs);
78
    }
79
}
80