Completed
Push — master ( cef25e...758dfd )
by Hilmi Erdem
02:56
created

GenericToken   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

4 Methods

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