| Total Complexity | 4 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 40% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Distilleries\Expendable\Models; |
||
| 4 | trait LockableTrait |
||
| 5 | { |
||
| 6 | protected $config_key_security_lock = 'expendable.auth.nb_of_try'; |
||
| 7 | protected $column_nb_of_try_name = 'nb_of_try'; |
||
| 8 | |||
| 9 | 2 | public function isLocked() |
|
| 10 | { |
||
| 11 | |||
| 12 | 2 | return ($this->{$this->column_nb_of_try_name} >= config($this->config_key_security_lock)); |
|
| 13 | |||
| 14 | } |
||
| 15 | |||
| 16 | public function incrementLock() |
||
| 17 | { |
||
| 18 | |||
| 19 | $this->{$this->column_nb_of_try_name} += 1; |
||
| 20 | \DB::table($this->getTable()) |
||
|
|
|||
| 21 | ->where($this->getKeyName(), $this->getKey()) |
||
| 22 | ->increment($this->column_nb_of_try_name); |
||
| 23 | return $this; |
||
| 24 | |||
| 25 | } |
||
| 26 | |||
| 27 | 4 | public function unlock() |
|
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | public function lock() |
||
| 48 | } |
||
| 49 | |||
| 50 | } |