Passed
Pull Request — master (#43)
by Tim
02:10
created

AsymmetricKey::readFile()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10

1 Method

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