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 ( 2e2b69...ec299f )
by Pascal
03:49
created

AbstractSslCertificateChecker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 16 4
1
<?php
2
3
namespace Pbmedia\ApiHealth\Checkers;
4
5
use Spatie\SslCertificate\Downloader;
6
use Spatie\SslCertificate\Exceptions\CouldNotDownloadCertificate;
7
8
abstract class AbstractSslCertificateChecker extends AbstractChecker
9
{
10
    /**
11
     * The hostname that must be checked.
12
     *
13
     * @var string
14
     */
15
    protected $hostname;
16
17
    /**
18
     * The port to request the certificate on.
19
     *
20
     * @var string
21
     */
22
    protected $port = 443;
23
24
    /**
25
     * Creates a new instance of this checker with a Ssl Certificate Downloader.
26
     *
27
     * @param \Spatie\SslCertificate\Downloader $downloader
28
     */
29
    public function __construct(Downloader $downloader)
30
    {
31
        $this->downloader = $downloader;
0 ignored issues
show
Bug introduced by
The property downloader does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32
    }
33
34
    /**
35
     * Requests the URL and handles any thrown exceptions.
36
     *
37
     * @return null
38
     */
39
    public function run()
40
    {
41
        try {
42
            $certificate = $this->downloader->usingPort($this->port)->forHost($this->hostname);
43
        } catch (InvalidUrl $urlException) {
0 ignored issues
show
Bug introduced by
The class Pbmedia\ApiHealth\Checkers\InvalidUrl does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
44
            throw new CheckerHasFailed("Could not check the Ssl Certificate for \"{$this->hostname}\": {$urlException->getMessage()}");
45
        } catch (CouldNotDownloadCertificate $downloadException) {
46
            throw new CheckerHasFailed("Could not download the Ssl Certificate for \"{$this->hostname}\": {$downloadException->getMessage()}");
47
        }
48
49
        if ($certificate->isValid()) {
50
            return;
51
        }
52
53
        throw new CheckerHasFailed("The Ssl Certificate for \"{$this->hostname}\" is not valid. The expiration date is {$certificate->expirationDate()}.");
54
    }
55
}
56