JWTEncrypter::encrypt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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