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
Push — master ( 1f0c23...177ac6 )
by Freek
01:50
created

SiteRepository   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 70
rs 10
c 3
b 0
f 0
wmc 7
lcom 0
cbo 2

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllForUptimeCheck() 0 11 1
A getAllForSslCheck() 0 7 1
A healthySites() 0 9 1
A downSites() 0 9 1
A withSslProblems() 0 9 1
A unhealthySites() 0 9 1
A uncheckedSites() 0 7 1
1
<?php
2
3
namespace Spatie\UptimeMonitor;
4
5
use Illuminate\Support\Collection;
6
use Spatie\UptimeMonitor\Models\Enums\SslCertificateStatus;
7
use Spatie\UptimeMonitor\Models\Enums\UptimeStatus;
8
use Spatie\UptimeMonitor\Models\Site;
9
use Spatie\UptimeMonitor\Services\PingMonitors\SiteCollection;
10
11
class SiteRepository
12
{
13
    public static function getAllForUptimeCheck(): SiteCollection
14
    {
15
        $sites = Site::enabled()
16
            ->orderBy('url')
17
            ->get()
18
            ->filter(function (Site $site) {
19
                return $site->shouldCheckUptime();
20
            });
21
22
        return new SiteCollection($sites);
23
    }
24
25
    public static function getAllForSslCheck(): Collection
26
    {
27
        return Site::enabled()
28
            ->orderBy('url')
29
            ->where('check_ssl_certificate', true)
30
            ->get();
31
    }
32
33
    public static function healthySites(): Collection
34
    {
35
        return Site::enabled()
36
            ->orderBy('url')
37
            ->get()
38
            ->filter(function (Site $site) {
39
                return $site->isHealthy();
40
            });
41
    }
42
43
    public static function downSites()
44
    {
45
        return Site::enabled()
46
            ->orderBy('url')
47
            ->get()
48
            ->filter(function (Site $site) {
49
                return $site->uptime_status == UptimeStatus::DOWN;
50
            });
51
    }
52
53
    public static function withSslProblems()
54
    {
55
        return Site::enabled()
56
            ->orderBy('url')
57
            ->get()
58
            ->filter(function (Site $site) {
59
                return $site->ssl_certificate_status == SslCertificateStatus::INVALID;
60
            });
61
    }
62
63
    public static function unhealthySites(): Collection
64
    {
65
        return Site::enabled()
66
            ->orderBy('url')
67
            ->get()
68
            ->reject(function (Site $site) {
69
                return $site->isHealthy();
70
            });
71
    }
72
73
    public static function uncheckedSites()
74
    {
75
        return Site::enabled()
76
            ->where('uptime_status', UptimeStatus::NOT_YET_CHECKED)
77
            ->orderBy('url')
78
            ->get();
79
    }
80
}
81