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 (#17)
by Freek
111:15 queued 61:06
created

CheckSslCertificates   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 24 2
1
<?php
2
3
namespace Spatie\UptimeMonitor\Commands;
4
5
use Spatie\SslCertificate\SslCertificate;
6
use Spatie\UptimeMonitor\Models\Enums\SslCertificateStatus;
7
use Spatie\UptimeMonitor\Models\Site;
8
use Spatie\UptimeMonitor\SiteRepository;
9
10
class CheckSslCertificates extends BaseCommand
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'uptime-monitor:check-ssl';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Check the ssl certificates of all sites';
25
26
    public function handle()
27
    {
28
        $sites = SiteRepository::getAllForSslCheck();
29
30
        $this->comment('Start checking the ssl certificate of '.count($sites).' sites...');
31
32
        SiteRepository::getAllForSslCheck()->each(function (Site $site) {
33
            $this->info("Checking ssl-certificate of {$site->url}");
34
35
            $certificate = SslCertificate::createForHostName($site->url->getHost());
36
37
            $site->ssl_certificate_status = $certificate->isValid()
38
                ? SslCertificateStatus::VALID
39
                : SslCertificateStatus::INVALID;
40
41
            $site->ssl_certificate_expiration_date = $certificate->expirationDate();
42
43
            $site->ssl_certificate_issuer = $certificate->getIssuer();
44
45
            $site->save();
46
        });
47
48
        $this->info('All done!');
49
    }
50
}
51