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

GenericToken::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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