Completed
Push — master ( 229a32...055b70 )
by Artem
02:23
created

DisableAccountTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 35
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEnabled() 0 8 2
A canAccountBeDisabled() 0 4 1
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
 * Trait for "disable account" feature.
18
 */
19
trait DisableAccountTrait
20
{
21
    /**
22
     * @var bool Whether account is enabled.
23
     *
24
     * @ORM\Column(name="enabled", type="boolean", nullable=false)
25
     */
26
    protected $isEnabled = true;
27
28
    /**
29
     * Disables or enables the account.
30
     *
31
     * @param bool $isEnabled New status of the account.
32
     *
33
     * @return self
34
     */
35 1
    public function setEnabled(bool $isEnabled)
36
    {
37 1
        if ($this->canAccountBeDisabled()) {
38 1
            $this->isEnabled = $isEnabled;
39
        }
40
41 1
        return $this;
42
    }
43
44
    /**
45
     * Specifies whether the "disable account" feature is available for this user.
46
     *
47
     * @return bool
48
     */
49 1
    protected function canAccountBeDisabled(): bool
50
    {
51 1
        return true;
52
    }
53
}
54