Completed
Push — master ( 6969ed...0fcf39 )
by Joao
11s queued 10s
created

JwtKeySecret   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 40
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getInstance() 0 4 1
A getPublicKey() 0 4 1
A getPrivateKey() 0 4 1
A getAlghoritm() 0 4 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
    public function __construct($key, $decode = true)
16
    {
17
        $this->key = ($decode ? base64_decode($key) : $key);
18
    }
19
20
    /**
21
     * @param $key
22
     * @param bool $decode
23
     * @return JwtKeySecret
24
     */
25
    public static function getInstance($key, $decode = true)
26
    {
27
        return new JwtKeySecret($key, $decode);
28
    }
29
30
    public function getPublicKey()
31
    {
32
        return $this->key;
33
    }
34
35
    public function getPrivateKey()
36
    {
37
        return $this->key;
38
    }
39
40
    public function getAlghoritm()
41
    {
42
        return 'HS512';
43
    }
44
}
45