Total Complexity | 7 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 58.81% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | final class CertificateTrustPath implements TrustPathInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var X509Certificate[] |
||
12 | */ |
||
13 | private $certificates; |
||
14 | |||
15 | 8 | public function __construct(X509Certificate ...$certificates) |
|
16 | { |
||
17 | 8 | foreach ($certificates as $c) { |
|
18 | 8 | if (!($c instanceof X509Certificate)) { |
|
19 | throw new InvalidArgumentException(sprintf('Expecting array of X509Certificate objects.')); |
||
20 | } |
||
21 | } |
||
22 | 8 | $this->certificates = $certificates; |
|
23 | 8 | } |
|
24 | |||
25 | public static function fromPemList(array $x5c): self |
||
30 | } |
||
31 | |||
32 | public static function fromBase64List(array $x5c): self |
||
33 | { |
||
34 | return new CertificateTrustPath(...array_map(static function (string $s): X509Certificate { |
||
35 | return X509Certificate::fromBase64($s); |
||
36 | }, $x5c)); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return X509Certificate[] |
||
41 | */ |
||
42 | 2 | public function getCertificates(): array |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Returns certificates as a list of PEM encoded strings (including armor). |
||
49 | * |
||
50 | * @return string[] |
||
51 | */ |
||
52 | 5 | public function asPemList(): array |
|
59 |