Passed
Push — master ( 5250f7...abb268 )
by IRFA
03:17
created

Lockout   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 28
c 3
b 0
f 2
dl 0
loc 53
rs 10
wmc 15

8 Methods

Rating   Name   Duplication   Size   Complexity  
A _lock() 0 2 1
A message() 0 2 1
A check() 0 14 4
A _check() 0 2 1
A lock() 0 9 3
A _unlock() 0 2 1
A clearLocked() 0 2 1
A unlock() 0 9 3
1
<?php 
2
namespace Irfa\Lockout\Func;
3
4
use Irfa\Lockout\Func\Core;
5
use View;
6
7
class Lockout extends Core {
8
	
9
    public function unlock($username){
10
        if(is_array($username)){
11
            foreach($username as $key){
12
                $this->_unlock($key);
13
            }
14
        } else{
15
            $this->_unlock($username);
16
        }
17
        return true;
18
    }
19
  
20
    public function message(){
21
    	return $this->showMessage();
22
    }
23
    public function lock($username){
24
        if(is_array($username)){
25
            foreach($username as $key){
26
                    $this->_lock($key);
27
            }
28
        } else{
29
                $this->_lock($username);
30
        }
31
        return true;
32
    }
33
    public function check($username) {	 
34
        $ret = null;
35
        if(is_array($username)){
36
            foreach($username as $key){
37
                $get = $this->_check($key);
38
                if(!empty($get)){
39
                    $ret[] = $get;
40
                }
41
            }
42
        } else{
43
                $ret = $this->_check($username);
44
        }
45
        $ret = json_encode($ret);
46
        return json_decode($ret);
47
    }
48
    public function clearLocked(){
49
        return $this->clear_all();
50
    }
51
52
    private function _unlock($username){
53
        $this->unlock_account($username);
54
    }
55
    private function _lock($username){
56
        $this->lock_account($username);
57
    }
58
    private function _check($username){
59
        return json_decode($this->check_account($username),true);
0 ignored issues
show
Bug introduced by
It seems like $this->check_account($username) can also be of type false; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
        return json_decode(/** @scrutinizer ignore-type */ $this->check_account($username),true);
Loading history...
60
    }
61
}
62