RequestTokenStorage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 35
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A save() 0 3 1
A get() 0 7 2
1
<?php
2
3
namespace Xsolve\SalesforceClient\Storage;
4
5
use Xsolve\SalesforceClient\Security\Token\TokenInterface;
6
7
class RequestTokenStorage implements TokenStorageInterface
8
{
9
    /**
10
     * @var TokenInterface|null
11
     */
12
    protected $token = null;
13
14
    /**
15
     * @return TokenInterface
16
     *
17
     * @throws \LogicException if the token is not set
18
     */
19 2
    public function get(): TokenInterface
20
    {
21 2
        if (!$this->has()) {
22 1
            throw new \LogicException('No token has been set');
23
        }
24
25 1
        return $this->token;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function has(): bool
32
    {
33 2
        return $this->token instanceof TokenInterface;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function save(TokenInterface $token)
40
    {
41 1
        $this->token = $token;
42 1
    }
43
}
44