Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Issues (184)

app/Classes/Breadcrumbs.php (3 issues)

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Marky
5
 * Date: 04/01/2018
6
 * Time: 01:28.
7
 */
8
9
namespace App\Classes;
10
11
use Illuminate\Http\Request;
12
use Illuminate\Support\Collection;
13
14
/**
15
 * Class Breadcrumbs.
16
 */
17
class Breadcrumbs
18
{
19
    /**
20
     * A collection of crumbs.
21
     *
22
     * @var Collection
23
     */
24
    protected $collection;
25
26
    /**
27
     * Breadcrumbs constructor.
28
     * @param Collection $collection
29
     */
30
    public function __construct(Collection $collection)
31
    {
32
        $this->collection = $collection;
33
    }
34
35
    /**
36
     * @param string $title
37
     * @param string $path
38
     * @return bool
39
     */
40
    public function addCrumb(string $title, string $path)
41
    {
42
        $crumb = new \stdClass();
43
        $crumb->title = $this->filter($title);
44
        $crumb->path = url($path);
45
46
        $this->collection->push($crumb);
47
48
        return true;
49
    }
50
51
    /**
52
     * @param string $title
53
     * @return string
54
     */
55
    public function filter(string $title)
56
    {
57
        return ucwords(str_replace(['_', '-'], [' ', ' '], $title));
58
    }
59
60
    /**
61
     * @return Collection
62
     */
63
    public function crumbs()
64
    {
65
        return $this->collection;
66
    }
67
68
    /**
69
     * @param string $name
70
     * @param int $position
71
     * @return bool
72
     */
73
    public function contain(string $name, int $position)
74
    {
75
        if ($this->collection->has($position) == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
76
            return false;
77
        }
78
79
        return $this->collection->get($position)->title == $this->filter($name);
80
    }
81
82
    /**
83
     * @param int $integer
84
     * @return bool
85
     */
86
    public function hasCount(int $integer)
87
    {
88
        return $this->collection->count() == $integer;
89
    }
90
91
    /**
92
     * @param int $count
93
     * @return $this
94
     */
95
    public function limit(int $count)
96
    {
97
        $collection = new Collection;
98
99
        for ($i = 0; $i < $count; $i++) {
100
            if ($this->collection->has($i)) {
101
                $collection->push($this->collection->get($i));
102
            }
103
        }
104
105
        $this->collection = $collection;
106
107
        return $this;
108
    }
109
110
    /**
111
     * @return Breadcrumbs
112
     */
113
    public static function fromCurrentRoute()
114
    {
115
        /** @var Breadcrumbs $instance */
116
        $instance = app(self::class);
117
118
        /** @var array $routes */
119
        $routes = explode('/', app(Request::class)->getRequestUri());
120
121
        $urlPath = url(array_pull($routes, 0));
122
123
        // Add the home array.
124
        $instance->addCrumb('Home', $urlPath);
0 ignored issues
show
It seems like $urlPath can also be of type Illuminate\Contracts\Routing\UrlGenerator; however, parameter $path of App\Classes\Breadcrumbs::addCrumb() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

124
        $instance->addCrumb('Home', /** @scrutinizer ignore-type */ $urlPath);
Loading history...
125
126
        foreach ($routes as $route) {
127
            $urlPath = $urlPath.'/'.$route;
0 ignored issues
show
Are you sure $urlPath of type string|Illuminate\Contracts\Routing\UrlGenerator can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

127
            $urlPath = /** @scrutinizer ignore-type */ $urlPath.'/'.$route;
Loading history...
128
129
            $instance->addCrumb($route, $urlPath);
130
        }
131
132
        return $instance;
133
    }
134
}
135