Completed
Push — master ( d8c018...19ac78 )
by Florent
06:38
created

Dir   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 2
Metric Value
wmc 3
c 2
b 1
f 2
lcom 0
cbo 3
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCEK() 0 7 1
A getAlgorithmName() 0 4 1
A getKeyManagementMode() 0 4 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Algorithm\KeyEncryption;
13
14
use Assert\Assertion;
15
use Base64Url\Base64Url;
16
use Jose\Object\JWKInterface;
17
18
final class Dir implements DirectEncryptionInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getCEK(JWKInterface $key)
24
    {
25
        Assertion::eq($key->get('kty'), 'oct', 'Wrong key type.');
26
        Assertion::true($key->has('k'), 'The key parameter "k" is missing.');
27
28
        return Base64Url::decode($key->get('k'));
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getAlgorithmName()
35
    {
36
        return 'dir';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getKeyManagementMode()
43
    {
44
        return self::MODE_DIRECT;
45
    }
46
}
47