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

DisableAccountTrait::canAccountBeDisabled()   A

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
//----------------------------------------------------------------------
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