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 ( 73f9d5...efcda2 )
by Freek
9s
created

CheckSslCertificates::handle()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 1
nop 0
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
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\Services\PingMonitors\UptimeMonitorCollection;
9
use Spatie\UptimeMonitor\SiteRepository;
10
11
class CheckSslCertificates extends BaseCommand
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'uptime-monitor:check-ssl';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Check the ssl certificates of all sites';
26
27
    public function handle()
28
    {
29
        $sites = SiteRepository::getAllForSslCheck();
30
31
        $this->comment('Start checking the ssl certificate of ' . count($sites) . ' sites...');
32
33
        SiteRepository::getAllForSslCheck()->each(function (Site $site) {
34
            $this->info("Checking ssl-certificate of {$site->url}");
35
36
            $certificate = SslCertificate::createForHostName($site->url->getHost());
37
38
            $site->ssl_certificate_status = $certificate->isValid()
39
                ? SslCertificateStatus::VALID
40
                : SslCertificateStatus::INVALID;
41
42
            $site->ssl_certificate_expiration_date = $certificate->expirationDate();
43
44
            $site->ssl_certificate_issuer = $certificate->getIssuer();
45
46
            $site->save();
47
        });
48
49
        $this->info('All done!');
50
    }
51
}
52