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
Branch php72 (a7f01e)
by Joni
04:53
created

PathValidationResult::policies()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\CertificationPath\PathValidation;
6
7
use Sop\ASN1\Element;
8
use Sop\CryptoTypes\AlgorithmIdentifier\Feature\AlgorithmIdentifierType;
9
use Sop\CryptoTypes\Asymmetric\PublicKeyInfo;
10
use Sop\X509\Certificate\Certificate;
11
use Sop\X509\Certificate\Extension\CertificatePolicy\PolicyInformation;
12
use Sop\X509\CertificationPath\Policy\PolicyTree;
13
14
/**
15
 * Result of the path validation process.
16
 *
17
 * @see https://tools.ietf.org/html/rfc5280#section-6.1.6
18
 */
19
class PathValidationResult
20
{
21
    /**
22
     * Certificates in a certification path.
23
     *
24
     * @var Certificate[]
25
     */
26
    protected $_certificates;
27
28
    /**
29
     * Valid policy tree.
30
     *
31
     * @var null|PolicyTree
32
     */
33
    protected $_policyTree;
34
35
    /**
36
     * End-entity certificate's public key.
37
     *
38
     * @var PublicKeyInfo
39
     */
40
    protected $_publicKeyInfo;
41
42
    /**
43
     * Public key algorithm.
44
     *
45
     * @var AlgorithmIdentifierType
46
     */
47
    protected $_publicKeyAlgo;
48
49
    /**
50
     * Public key parameters.
51
     *
52
     * @var null|Element
53
     */
54
    protected $_publicKeyParameters;
55
56
    /**
57
     * Constructor.
58
     *
59
     * @param Certificate[]           $certificates Certificates in a certification path
60
     * @param null|PolicyTree         $policy_tree  Valid policy tree
61
     * @param PublicKeyInfo           $pubkey_info  Public key of the end-entity certificate
62
     * @param AlgorithmIdentifierType $algo         Public key algorithm of the end-entity certificate
63
     * @param null|Element            $params       Algorithm parameters
64
     */
65 28
    public function __construct(array $certificates, ?PolicyTree $policy_tree,
66
        PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo,
67
        ?Element $params = null)
68
    {
69 28
        $this->_certificates = array_values($certificates);
70 28
        $this->_policyTree = $policy_tree;
71 28
        $this->_publicKeyInfo = $pubkey_info;
72 28
        $this->_publicKeyAlgo = $algo;
73 28
        $this->_publicKeyParameters = $params;
74 28
    }
75
76
    /**
77
     * Get end-entity certificate.
78
     *
79
     * @return Certificate
80
     */
81 12
    public function certificate(): Certificate
82
    {
83 12
        return $this->_certificates[count($this->_certificates) - 1];
84
    }
85
86
    /**
87
     * Get certificate policies of the end-entity certificate.
88
     *
89
     * @return PolicyInformation[]
90
     */
91 6
    public function policies(): array
92
    {
93 6
        if (!$this->_policyTree) {
94 1
            return [];
95
        }
96 5
        return $this->_policyTree->policiesAtDepth(count($this->_certificates));
97
    }
98
}
99