DirectAlgorithm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 31
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wrapNewKey() 0 4 1
A unwrap() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the tmilos/jose-jwt package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\JoseJwt\Jwe;
13
14
use Tmilos\JoseJwt\Error\JoseJwtException;
15
16
class DirectAlgorithm implements JweAlgorithm
17
{
18
    /**
19
     * @param int             $cekSizeBits
20
     * @param string|resource $kek
21
     * @param array           $header
22
     *
23
     * @return array [cek, encryptedCek]
24
     */
25
    public function wrapNewKey($cekSizeBits, $kek, array $header)
26
    {
27
        return [$kek, ''];
28
    }
29
30
    /**
31
     * @param string          $encryptedCek
32
     * @param string|resource $key
33
     * @param int             $cekSizeBits
34
     * @param array           $header
35
     *
36
     * @return string
37
     */
38
    public function unwrap($encryptedCek, $key, $cekSizeBits, array $header)
39
    {
40
        if ($encryptedCek) {
41
            throw new JoseJwtException('Direct algorithm expects empty content encryption key');
42
        }
43
44
        return $key;
0 ignored issues
show
Bug Compatibility introduced by
The expression return $key; of type string|resource is incompatible with the return type declared by the interface Tmilos\JoseJwt\Jwe\JweAlgorithm::unwrap of type string as it can also be of type resource which is not included in this return type.
Loading history...
45
    }
46
}
47