AsymmetricKey   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPEM() 0 3 1
A __construct() 0 3 1
A getMaterial() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Key;
6
7
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
8
9
/**
10
 * A class representing an asymmetric key.
11
 *
12
 * This class can be extended to implement public or private keys.
13
 *
14
 * @package simplesamlphp/xml-security
15
 */
16
abstract class AsymmetricKey implements KeyInterface
17
{
18
    /**
19
     * Build a new key with $key as its material.
20
     *
21
     * @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $material The associated key material.
22
     */
23
    public function __construct(
24
        protected PEM $material,
25
    ) {
26
    }
27
28
29
    /**
30
     * Return the key material associated with this key.
31
     *
32
     * @return string The key material.
33
     */
34
    public function getMaterial(): string
35
    {
36
        return $this->material->string();
37
    }
38
39
40
    /**
41
     * Return the raw PEM-object associated with this key.
42
     *
43
     * @return \SimpleSAML\XMLSecurity\CryptoEncoding\PEM The raw material.
44
     */
45
    public function getPEM(): PEM
46
    {
47
        return $this->material;
48
    }
49
}
50