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 ( e4bf89...f3fb4c )
by Freek
01:59
created

CheckSslCertificates::handle()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 27
Code Lines 15

Duplication

Lines 5
Ratio 18.52 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 2
nop 0
dl 5
loc 27
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Commands;
4
5
use Spatie\SslCertificate\Exceptions\CouldNotDownloadCertificate;
6
use Spatie\SslCertificate\SslCertificate;
7
use Spatie\UptimeMonitor\Models\Site;
8
use Spatie\UptimeMonitor\SiteRepository;
9
10
class CheckSslCertificates extends BaseCommand
11
{
12
    protected $signature = 'sites:check-ssl
13
                           {--url= : Only check these urls}';
14
15
16
    protected $description = 'Check the ssl certificates of all sites';
17
18
    public function handle()
19
    {
20
        $sites = SiteRepository::getAllForSslCheck();
21
22 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...
23
            $sites = $sites->filter(function(Site $site) use ($url) {
24
                return in_array((string)$site->url, explode(',', $url));
25
            });
26
        };
27
28
        $this->comment('Start checking the ssl certificate of '.count($sites).' sites...');
29
30
        $sites->each(function (Site $site) {
31
            $this->info("Checking ssl-certificate of {$site->url}");
32
33
            try {
34
                $certificate = SslCertificate::createForHostName($site->url->getHost());
35
36
                $site->updateWithCertificate($certificate);
37
            } catch (CouldNotDownloadCertificate $exception) {
38
                $this->error("Could not download certifcate of {$site->url} because: {$exception->getMessage()}");
39
                $site->updateWithCertificateException($exception);
40
            }
41
        });
42
43
        $this->info('All done!');
44
    }
45
}
46