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 ( 7eca44...e8b188 )
by Freek
02:30
created

SiteRepository   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 6
Bugs 0 Features 0
Metric Value
dl 0
loc 75
rs 10
c 6
b 0
f 0
wmc 8
lcom 0
cbo 2

8 Methods

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