RequestTokenStorage::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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