Completed
Push — master ( 055b70...427a37 )
by Artem
03:41
created

UserTrait   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 19
lcom 0
cbo 4
dl 0
loc 97
ccs 28
cts 28
cp 1
rs 10
c 1
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getPassword() 0 4 1
A getSalt() 0 4 1
A eraseCredentials() 0 3 1
A isEnabled() 0 9 3
A isAccountNonExpired() 0 11 4
A isCredentialsNonExpired() 0 11 4
B isAccountNonLocked() 0 11 5
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2017 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <http://opensource.org/licenses/MIT>.
9
//
10
//----------------------------------------------------------------------
11
12
namespace Pignus\Model;
13
14
use Doctrine\ORM\Mapping as ORM;
15
16
/**
17
 * User trait.
18
 *
19
 * @ORM\MappedSuperclass(repositoryClass="Pignus\Model\UserRepositoryInterface")
20
 */
21
trait UserTrait
22
{
23
    /**
24
     * @see \Symfony\Component\Security\Core\User\UserInterface
25
     *
26
     * {@inheritdoc}
27
     */
28 1
    public function getPassword()
29
    {
30 1
        return null;
31
    }
32
33
    /**
34
     * @see \Symfony\Component\Security\Core\User\UserInterface
35
     *
36
     * {@inheritdoc}
37
     */
38 1
    public function getSalt()
39
    {
40 1
        return null;
41
    }
42
43
    /**
44
     * @see \Symfony\Component\Security\Core\User\UserInterface
45
     *
46
     * {@inheritdoc}
47
     */
48 1
    public function eraseCredentials()
49
    {
50 1
    }
51
52
    /**
53
     * @see \Symfony\Component\Security\Core\User\AdvancedUserInterface
54
     *
55
     * {@inheritdoc}
56
     */
57 2
    public function isEnabled()
58
    {
59 2
        if (in_array(DisableAccountTrait::class, class_uses($this), true)) {
60
            /** @var DisableAccountTrait $this */
61 1
            return $this->canAccountBeDisabled() ? $this->isEnabled : true;
0 ignored issues
show
Bug introduced by
The property isEnabled cannot be accessed from this context as it is declared protected in class Pignus\Model\DisableAccountTrait.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
62
        }
63
64 1
        return true;
65
    }
66
67
    /**
68
     * @see \Symfony\Component\Security\Core\User\AdvancedUserInterface
69
     *
70
     * {@inheritdoc}
71
     */
72 3
    public function isAccountNonExpired()
73
    {
74 3
        if (in_array(ExpireAccountTrait::class, class_uses($this), true)) {
75
            /** @var ExpireAccountTrait $this */
76 2
            return $this->canAccountBeExpired()
77 2
                ? $this->accountExpiresAt === null || $this->accountExpiresAt > time()
0 ignored issues
show
Bug introduced by
The property accountExpiresAt cannot be accessed from this context as it is declared protected in class Pignus\Model\ExpireAccountTrait.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
78 2
                : true;
79
        }
80
81 1
        return true;
82
    }
83
84
    /**
85
     * @see \Symfony\Component\Security\Core\User\AdvancedUserInterface
86
     *
87
     * {@inheritdoc}
88
     */
89 3
    public function isCredentialsNonExpired()
90
    {
91 3
        if (in_array(ExpirePasswordTrait::class, class_uses($this), true)) {
92
            /** @var ExpirePasswordTrait $this */
93 2
            return $this->canPasswordBeExpired()
94 2
                ? $this->passwordExpiresAt === null || $this->passwordExpiresAt > time()
0 ignored issues
show
Bug introduced by
The property passwordExpiresAt cannot be accessed from this context as it is declared protected in class Pignus\Model\ExpirePasswordTrait.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
95 2
                : true;
96
        }
97
98 1
        return true;
99
    }
100
101
    /**
102
     * @see \Symfony\Component\Security\Core\User\AdvancedUserInterface
103
     *
104
     * {@inheritdoc}
105
     */
106 7
    public function isAccountNonLocked()
107
    {
108 7
        if (in_array(LockAccountTrait::class, class_uses($this), true)) {
109
            /** @var LockAccountTrait $this */
110 6
            return $this->canAccountBeLocked()
111 6
                ? $this->lockedUntil === null || $this->lockedUntil !== 0 && $this->lockedUntil <= time()
0 ignored issues
show
Bug introduced by
The property lockedUntil cannot be accessed from this context as it is declared protected in class Pignus\Model\LockAccountTrait.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
112 6
                : true;
113
        }
114
115 1
        return true;
116
    }
117
}
118