Token::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Xsolve\SalesforceClient\Security\Token;
4
5
/**
6
 * Basic implementation of TokenInterace.
7
 */
8
class Token implements TokenInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $tokenType;
14
15
    /**
16
     * @var string
17
     */
18
    protected $accessToken;
19
20
    /**
21
     * @var string
22
     */
23
    protected $refreshToken;
24
25
    /**
26
     * @var string
27
     */
28
    protected $instanceUrl;
29
30
    /**
31
     * @param string $tokenType
32
     * @param string $accessToken
33
     * @param string $instanceUrl
34
     * @param string $refreshToken
35
     */
36 3
    public function __construct(string $tokenType, string $accessToken, string $instanceUrl, string $refreshToken = '')
37
    {
38 3
        $this->tokenType = $tokenType;
39 3
        $this->accessToken = $accessToken;
40 3
        $this->refreshToken = $refreshToken;
41 3
        $this->instanceUrl = $instanceUrl;
42 3
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 1
    public function getTokenType(): string
48
    {
49 1
        return $this->tokenType;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function getAccessToken(): string
56
    {
57 1
        return $this->accessToken;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function getRefreshToken(): string
64
    {
65 1
        return $this->refreshToken;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    public function getInstanceUrl(): string
72
    {
73 1
        return $this->instanceUrl;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 1
    public function serialize(): string
80
    {
81 1
        return serialize([
82 1
            $this->tokenType,
83 1
            $this->accessToken,
84 1
            $this->instanceUrl,
85 1
            $this->refreshToken,
86
        ]);
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92 1
    public function unserialize($serialized)
93
    {
94
        list(
95 1
            $this->tokenType,
96 1
            $this->accessToken,
97 1
            $this->instanceUrl,
98 1
            $this->refreshToken
99 1
        ) = unserialize($serialized);
100 1
    }
101
}
102