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.

AbstractSslCertificateChecker   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 4
A __construct() 0 3 1
1
<?php
2
3
namespace ProtoneMedia\ApiHealth\Checkers;
4
5
use Spatie\SslCertificate\Downloader;
6
use Spatie\SslCertificate\Exceptions\CouldNotDownloadCertificate;
7
use Spatie\SslCertificate\Exceptions\InvalidUrl;
8
9
abstract class AbstractSslCertificateChecker extends AbstractChecker
10
{
11
    /**
12
     * The Spatie SSL downloader.
13
     *
14
     * @var \Spatie\SslCertificate\Downloader $downloader
15
     */
16
    protected $downloader;
17
18
    /**
19
     * The hostname that must be checked.
20
     *
21
     * @var string
22
     */
23
    protected $hostname;
24
25
    /**
26
     * The port to request the certificate on.
27
     *
28
     * @var string
29
     */
30
    protected $port = 443;
31
32
    /**
33
     * Creates a new instance of this checker with a Ssl Certificate Downloader.
34
     *
35
     * @param \Spatie\SslCertificate\Downloader $downloader
36
     */
37
    public function __construct(Downloader $downloader)
38
    {
39
        $this->downloader = $downloader;
40
    }
41
42
    /**
43
     * Requests the URL and handles any thrown exceptions.
44
     *
45
     * @return null
46
     */
47
    public function run()
48
    {
49
        try {
50
            $certificate = $this->downloader->usingPort($this->port)->forHost($this->hostname);
0 ignored issues
show
Bug introduced by
$this->port of type string is incompatible with the type integer expected by parameter $port of Spatie\SslCertificate\Downloader::usingPort(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

50
            $certificate = $this->downloader->usingPort(/** @scrutinizer ignore-type */ $this->port)->forHost($this->hostname);
Loading history...
51
        } catch (InvalidUrl $urlException) {
52
            throw new CheckerHasFailed("Could not check the Ssl Certificate for \"{$this->hostname}\": {$urlException->getMessage()}");
53
        } catch (CouldNotDownloadCertificate $downloadException) {
54
            throw new CheckerHasFailed("Could not download the Ssl Certificate for \"{$this->hostname}\": {$downloadException->getMessage()}");
55
        }
56
57
        if ($certificate->isValid()) {
58
            return;
59
        }
60
61
        throw new CheckerHasFailed("The Ssl Certificate for \"{$this->hostname}\" is not valid. The expiration date is {$certificate->expirationDate()}.");
62
    }
63
}
64