JwtKeySecret::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
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