JwtKeySecret   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 7
c 1
b 0
f 0
dl 0
loc 38
ccs 10
cts 10
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlghoritm() 0 3 1
A getPublicKey() 0 3 1
A getPrivateKey() 0 3 1
A __construct() 0 3 2
A getInstance() 0 3 1
1
<?php
2
3
namespace ByJG\Util;
4
5
class JwtKeySecret implements JwtKeyInterface
6
{
7
8
    protected $key;
9
10
    /**
11
     * JwtKeySecret constructor.
12
     * @param $key
13
     * @param bool $decode
14
     */
15 9
    public function __construct($key, $decode = true)
16
    {
17 9
        $this->key = ($decode ? base64_decode($key) : $key);
18
    }
19
20
    /**
21
     * @param $key
22
     * @param bool $decode
23
     * @return JwtKeySecret
24
     */
25 9
    public static function getInstance($key, $decode = true)
26
    {
27 9
        return new JwtKeySecret($key, $decode);
28
    }
29
30 8
    public function getPublicKey()
31
    {
32 8
        return $this->key;
33
    }
34
35 6
    public function getPrivateKey()
36
    {
37 6
        return $this->key;
38
    }
39
40 8
    public function getAlghoritm()
41
    {
42 8
        return 'HS512';
43
    }
44
}
45