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.
Completed
Pull Request — master (#52)
by
unknown
19:57
created

MonitorCollection::getPromises()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor;
4
5
use Illuminate\Support\Collection;
6
use Spatie\UptimeMonitor\Checker\Checker;
7
use Spatie\UptimeMonitor\Checker\CheckerRepository;
8
use Spatie\UptimeMonitor\Models\Monitor;
9
10
class MonitorCollection extends Collection
11
{
12
    /**
13
     * @return static
14
     */
15
    public function sortByHost()
16
    {
17
        return $this->sortBy(function (Monitor $monitor) {
18
            return $monitor->url->getHost();
19
        });
20
    }
21
22
    public function checkUptime()
23
    {
24
        $this->resetItemKeys();
25
        foreach (CheckerRepository::get()->getChecker() as $protocol => $checker) {
26
            /*
27
             * @var $checker Checker
28
             */
29
            $checker->check($this->filter(function ($value) use ($protocol) {
30
                if (! ends_with($protocol, '*')) {
31
                    $protocol = $protocol.'*';
0 ignored issues
show
Bug introduced by
Consider using a different name than the imported variable $protocol, or did you forget to import by reference?

It seems like you are assigning to a variable which was imported through a use statement which was not imported by reference.

For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.

Change not visible in outer-scope

$x = 1;
$callable = function() use ($x) {
    $x = 2; // Not visible in outer scope. If you would like this, how
            // about using a different variable name than $x?
};

$callable();
var_dump($x); // integer(1)

Change visible in outer-scope

$x = 1;
$callable = function() use (&$x) {
    $x = 2;
};

$callable();
var_dump($x); // integer(2)
Loading history...
32
                }
33
34
                return str_is($protocol, $value->url->getScheme());
35
            }));
36
        }
37
    }
38
39
    /**
40
     * In order to make use of Guzzle promises we have to make sure the
41
     * keys of the collection are in a consecutive order without gaps.
42
     */
43
    public function resetItemKeys()
44
    {
45
        $this->items = $this->values()->all();
46
    }
47
48
    public function getMonitorAtIndex(int $index): Monitor
49
    {
50
        return $this->items[$index];
51
    }
52
}
53