QualifiedCertificate   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 52
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A subject() 0 4 1
A getPath() 0 4 1
A getValidationResult() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bip70\X509;
6
7
use Bip70\Exception\X509Exception;
8
use X501\ASN1\Name;
9
use X509\CertificationPath\CertificationPath;
10
use X509\CertificationPath\PathValidation\PathValidationResult;
11
12
class QualifiedCertificate
13
{
14
    /**
15
     * @var CertificationPath
16
     */
17
    private $path;
18
19
    /**
20
     * @var PathValidationResult
21
     */
22
    private $validationResult;
23
24
    /**
25
     * QualifiedCertificate constructor.
26
     * @param CertificationPath $path
27
     * @param PathValidationResult $result
28
     * @throws X509Exception
29
     */
30 6
    public function __construct(CertificationPath $path, PathValidationResult $result)
31
    {
32 6
        if (!$result->certificate()->equals($path->endEntityCertificate())) {
33 1
            throw new X509Exception("CertificationPath entity certificate must match PathValidationResult certificate");
34
        }
35
36 6
        $this->path = $path;
37 6
        $this->validationResult = $result;
38 6
    }
39
40
    /**
41
     * @return Name
42
     */
43 1
    public function subject(): Name
44
    {
45 1
        return $this->path->endEntityCertificate()->tbsCertificate()->subject();
46
    }
47
48
    /**
49
     * @return CertificationPath
50
     */
51 3
    public function getPath(): CertificationPath
52
    {
53 3
        return $this->path;
54
    }
55
56
    /**
57
     * @return PathValidationResult
58
     */
59 4
    public function getValidationResult(): PathValidationResult
60
    {
61 4
        return $this->validationResult;
62
    }
63
}
64