Completed
Push — master ( 96bb9e...dc511e )
by Hilmi Erdem
02:05
created

GenericToken   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 59
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A plain() 0 4 1
A encrypted() 0 5 1
A __toString() 0 4 1
1
<?php
2
3
namespace Erdemkeren\TemporaryAccess;
4
5
use Erdemkeren\TemporaryAccess\Contracts\TokenInterface;
6
7
final class GenericToken implements TokenInterface
8
{
9
    /**
10
     * The plain text.
11
     *
12
     * @var string|null
13
     */
14
    private $plainText;
15
16
    /**
17
     * The encrypted text.
18
     *
19
     * @var string
20
     */
21
    private $encryptedText;
22
23
    /**
24
     * GenericToken constructor.
25
     *
26
     * @param  string      $encryptedText The encrypted text.
27
     * @param  string|null $plainText     The plain text string.
28
     */
29 6
    public function __construct($encryptedText, $plainText = null)
30
    {
31 6
        $this->plainText = $plainText;
32 6
        $this->encryptedText = $encryptedText;
33 6
    }
34
35
    /**
36
     * Get the token as plain text.
37
     *
38
     * @return string|null
39
     */
40 4
    public function plain()
41
    {
42 4
        return $this->plainText;
43
    }
44
45
    /**
46
     * Get the token as encrypted text.
47
     *
48
     * @return string
49
     */
50 5
    public function encrypted()
51
    {
52 5
        return $this->encryptedText;
53
54
    }
55
56
    /**
57
     * Convert the token to string.
58
     *
59
     * @return string
60
     */
61 1
    public function __toString()
62
    {
63 1
        return $this->encrypted();
64
    }
65
}
66