| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | * Checks whether the user is enabled. |
||
| 30 | * |
||
| 31 | * Inherited from '\Symfony\Component\Security\Core\User\AdvancedUserInterface'. |
||
| 32 | * |
||
| 33 | * @return bool TRUE if the user is enabled, FALSE otherwise. |
||
| 34 | */ |
||
| 35 | 4 | public function isEnabled(): bool |
|
| 36 | { |
||
| 37 | 4 | return $this->canAccountBeDisabled() ? $this->isEnabled : true; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Disables or enables the account. |
||
| 42 | * |
||
| 43 | * @param bool $isEnabled New status of the account. |
||
| 44 | * |
||
| 45 | * @return self |
||
| 46 | */ |
||
| 47 | 2 | public function setEnabled(bool $isEnabled): self |
|
| 48 | { |
||
| 49 | 2 | if ($this->canAccountBeDisabled()) { |
|
| 50 | 2 | $this->isEnabled = $isEnabled; |
|
| 51 | } |
||
| 52 | |||
| 53 | 2 | return $this; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Specifies whether the "disable account" feature is available for this user. |
||
| 58 | * |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | 4 | protected function canAccountBeDisabled(): bool |
|
| 64 | } |
||
| 65 | } |
||
| 66 |