NetteTokenAdapter::eraseCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify.
7
 * Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Symplify\SymfonySecurity\Core\Authentication\Token;
11
12
use Nette\Security\Identity;
13
use Nette\Security\IIdentity;
14
use Nette\Security\User;
15
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
16
use Symplify\SymfonySecurity\Exception\NotImplementedException;
17
18
final class NetteTokenAdapter implements TokenInterface
19
{
20
    /**
21
     * @var User
22
     */
23
    private $user;
24
25 1
    public function serialize()
26
    {
27 1
        throw new NotImplementedException();
28
    }
29
30
    /**
31
     * @param string $serialized
32
     */
33 1
    public function unserialize($serialized)
34
    {
35 1
        throw new NotImplementedException();
36
    }
37
38 1
    public function __toString()
39
    {
40 1
        throw new NotImplementedException();
41
    }
42
43 1
    public function getRoles() : array
44
    {
45 1
        return $this->user->getRoles();
46
    }
47
48
    /**
49
     * @return IIdentity|null
50
     */
51 1
    public function getCredentials()
52
    {
53 1
        return $this->user->getIdentity();
54
    }
55
56
    /**
57
     * @return User
58
     */
59 1
    public function getUser()
60
    {
61 1
        return $this->user;
62
    }
63
64
    /**
65
     * @param User $user
66
     */
67 15
    public function setUser($user)
68
    {
69 15
        $this->user = $user;
70 15
    }
71
72 1
    public function getUsername() : bool
73
    {
74 1
        return false;
75
    }
76
77 2
    public function isAuthenticated() : bool
78
    {
79 2
        return $this->user->isLoggedIn();
80
    }
81
82
    /**
83
     * @param bool $isAuthenticated
84
     */
85 1
    public function setAuthenticated($isAuthenticated)
86
    {
87 1
        $this->user->getStorage()->setAuthenticated($isAuthenticated);
88 1
    }
89
90 1
    public function eraseCredentials()
91
    {
92 1
        throw new NotImplementedException();
93
    }
94
95 1
    public function getAttributes() : array
96
    {
97
        /** @var Identity $identity */
98 1
        $identity = $this->user->getIdentity();
99
100 1
        return (array) $identity->getData();
101
    }
102
103 1
    public function setAttributes(array $attributes)
104
    {
105 1
        throw new NotImplementedException();
106
    }
107
108
    /**
109
     * @param string $name
110
     */
111 1
    public function hasAttribute($name) : bool
112
    {
113 1
        return false;
114
    }
115
116
    /**
117
     * @param string $name
118
     */
119 1
    public function getAttribute($name) : bool
120
    {
121 1
        return false;
122
    }
123
124
    /**
125
     * @param string $name
126
     * @param mixed $value
127
     */
128 1
    public function setAttribute($name, $value)
129
    {
130 1
        throw new NotImplementedException();
131
    }
132
}
133