JWTEncrypter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A encrypt() 0 4 1
A decrypt() 0 4 1
1
<?php
2
3
namespace WZRD\Encryption;
4
5
use JWT;
6
use WZRD\Contracts\Encryption\Encrypter;
7
8
class JWTEncrypter implements Encrypter
9
{
10
    /**
11
     * Security key.
12
     *
13
     * @var string
14
     */
15
    private $key;
16
17
    /**
18
     * Initialize hash with security key.
19
     *
20
     * @param string $key
21
     */
22
    public function __construct($key)
23
    {
24
        $this->key = $key;
25
    }
26
27
    /**
28
     * Encrypt the given value.
29
     *
30
     * @param mixed $value
31
     *
32
     * @return string
33
     */
34
    public function encrypt($value)
35
    {
36
        return JWT::encode($value, $this->key);
37
    }
38
39
    /**
40
     * Decrypt the given value.
41
     *
42
     * @param string $value
43
     *
44
     * @return mixed
45
     */
46
    public function decrypt($value)
47
    {
48
        return JWT::decode($value, $this->key);
49
    }
50
}
51