KeyChain   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A defaultCipherType() 0 4 1
A keychainPrivateXmlSecurityKey() 0 10 1
1
<?php
2
3
4
namespace flipbox\saml\core\records\traits;
5
6
use flipbox\keychain\records\KeyChainRecord;
7
use flipbox\saml\core\records\AbstractProvider;
8
use RobRichards\XMLSecLibs\XMLSecurityKey;
9
10
/**
11
 * Trait KeyPair
12
 * @package flipbox\saml\core\records\traits
13
 * @property KeyChainRecord $keychain
14
 * @mixin AbstractProvider
15
 */
16
trait KeyChain
17
{
18
    /**
19
     * @return string
20
     */
21
    public function defaultCipherType()
22
    {
23
        return XMLSecurityKey::RSA_SHA256;
24
    }
25
26
    /**
27
     * @return XMLSecurityKey
28
     * @throws \Exception
29
     */
30
    public function keychainPrivateXmlSecurityKey()
31
    {
32
        $xmlSecurityKey = new XMLSecurityKey($this->defaultCipherType(), [
33
            'type' => 'private',
34
        ]);
35
36
        $xmlSecurityKey->loadKey($this->keychain->getDecryptedKey());
37
38
        return $xmlSecurityKey;
39
    }
40
}
41