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 ( 96add5...9e1bcf )
by Nick
02:40
created

Certificate   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 93.1%

Importance

Changes 4
Bugs 0 Features 4
Metric Value
wmc 10
c 4
b 0
f 4
lcom 1
cbo 1
dl 0
loc 97
ccs 27
cts 29
cp 0.931
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A validFrom() 0 6 1
A validTo() 0 6 1
A certName() 0 4 1
A subject() 0 4 1
A issuer() 0 4 1
A sans() 0 4 1
A toString() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace Punkstar\Ssl;
4
5
use DateTime;
6
use Punkstar\Ssl\Parser\SanParser;
7
8
class Certificate
9
{
10
    protected $rawCert;
11
    protected $certData;
12
13
    /**
14
     * @var SanParser
15
     */
16
    protected $sanParser;
17
18
    /**
19
     * Certificate constructor.
20
     *
21
     * @param string $certificate
22
     * @param SanParser $sanParser
23
     */
24 7
    public function __construct($certificate, SanParser $sanParser = null)
25
    {
26 7
        if ($sanParser === null) {
27 7
            $sanParser = new SanParser();
28 7
        }
29
30 7
        $this->sanParser = $sanParser;
31
32 7
        $this->rawCert = $certificate;
33 7
        $this->certData = openssl_x509_parse($this->rawCert);
34 7
        $this->sanParser = $sanParser;
35 7
    }
36
37
    /**
38
     * @return DateTime
39
     */
40 3
    public function validFrom()
41
    {
42 3
        $date = new DateTime();
43 3
        $date->setTimestamp($this->certData['validFrom_time_t']);
44 3
        return $date;
45
    }
46
47
    /**
48
     * @return DateTime
49
     */
50 3
    public function validTo()
51
    {
52 3
        $date = new DateTime();
53 3
        $date->setTimestamp($this->certData['validTo_time_t']);
54 3
        return $date;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 3
    public function certName()
61
    {
62 3
        return $this->certData['name'];
63
    }
64
65
    /**
66
     * @return array
67
     */
68 3
    public function subject()
69
    {
70 3
        return $this->certData['subject'];
71
    }
72
73
    /**
74
     * @return array
75
     */
76 3
    public function issuer()
77
    {
78 3
        return $this->certData['issuer'];
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function sans()
85
    {
86
        return $this->sanParser->parse($this->certData['extensions']['subjectAltName']);
87
    }
88
89
    /**
90
     * @return string
91
     */
92 6
    public function toString()
93
    {
94 6
        return $this->rawCert;
95
    }
96
97
    /**
98
     * @return string
99
     */
100 6
    public function __toString()
101
    {
102 6
        return $this->toString();
103
    }
104
}
105