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

GenericToken::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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