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.

CheckCertificates::handle()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 24

Duplication

Lines 5
Ratio 20.83 %

Importance

Changes 0
Metric Value
dl 5
loc 24
rs 9.536
c 0
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Commands;
4
5
use Spatie\UptimeMonitor\Models\Enums\CertificateStatus;
6
use Spatie\UptimeMonitor\Models\Monitor;
7
use Spatie\UptimeMonitor\MonitorRepository;
8
9
class CheckCertificates extends BaseCommand
10
{
11
    protected $signature = 'monitor:check-certificate
12
                           {--url= : Only check these urls}';
13
14
    protected $description = 'Check the certificates of all sites';
15
16
    public function handle()
17
    {
18
        $monitors = MonitorRepository::getForCertificateCheck();
19
20 View Code Duplication
        if ($url = $this->option('url')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
            $monitors = $monitors->filter(function (Monitor $monitor) use ($url) {
22
                return in_array((string) $monitor->url, explode(',', $url));
23
            });
24
        }
25
26
        $this->comment('Start checking the certificates of '.count($monitors).' monitors...');
27
28
        $monitors->each(function (Monitor $monitor) {
29
            $this->info("Checking certificate of {$monitor->url}");
30
31
            $monitor->checkCertificate();
32
33
            if ($monitor->certificate_status !== CertificateStatus::VALID) {
34
                $this->error("Could not download certificate of {$monitor->url} because: {$monitor->certificate_check_failure_reason}");
35
            }
36
        });
37
38
        $this->info('All done!');
39
    }
40
}
41