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.

CertificateChain::getContentOfCompleteChain()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Spatie\CertificateChain;
4
5
class CertificateChain
6
{
7
    protected $certificates;
8
9
    public static function fetchForCertificate(Certificate $certificate)
10
    {
11
        return (new static($certificate))->getContentOfCompleteChain();
12
    }
13
14
    public function __construct(Certificate $certificate)
15
    {
16
        $this->certificates = collect()->push($certificate);
17
    }
18
19
    public function getContentOfCompleteChain(): string
20
    {
21
        while ($this->lastCertificate()->hasParentInTrustChain()) {
22
            $this->certificates->push($this->lastCertificate()->fetchParentCertificate());
23
        }
24
25
        return $this->certificates->map(function (Certificate $certificate) {
26
            return $certificate->getContents();
27
        })->implode('');
28
    }
29
30
    protected function lastCertificate(): Certificate
31
    {
32
        return $this->certificates->last();
33
    }
34
}
35