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

UserTrait::isAccountNonLocked()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 8.8571
c 1
b 0
f 0
cc 5
eloc 6
nc 7
nop 0
crap 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