AsymmetricKey::getPEM()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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