WhiteList::isWhiteListed()   B
last analyzed

Complexity

Conditions 7
Paths 48

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 11
cts 11
cp 1
rs 8.6666
c 0
b 0
f 0
cc 7
nc 48
nop 0
crap 7
1
<?php
2
3
namespace Botonomous;
4
5
class WhiteList extends AbstractAccessList
6
{
7
    /**
8
     * WhiteList constructor.
9
     *
10
     * @param $request
11
     */
12 12
    public function __construct($request)
13
    {
14 12
        $this->setRequest($request);
15 12
    }
16
17
    /**
18
     * @throws \Exception
19
     *
20
     * @return bool
21
     */
22 3
    public function isWhiteListed(): bool
23
    {
24 3
        $usernameCheck = true;
25 3
        $userIdCheck = true;
26 3
        $userEmailCheck = true;
27
28 3
        if ($this->isUsernameWhiteListed() === false) {
29 2
            $usernameCheck = false;
30
        }
31
32 3
        if ($this->isUserIdWhiteListed() === false) {
33 2
            $userIdCheck = false;
34
        }
35
36 3
        if ($this->isEmailWhiteListed() === false) {
37 2
            $userEmailCheck = false;
38
        }
39
40 3
        return $usernameCheck === true && $userIdCheck === true && $userEmailCheck === true ? true : false;
41
    }
42
43
    /**
44
     * @throws \Exception
45
     *
46
     * @return bool
47
     */
48 4
    public function isUsernameWhiteListed(): bool
49
    {
50 4
        return empty($this->findInListByRequestKey('user_name', $this->getShortClassName(), 'username')) ? false : true;
51
    }
52
53
    /**
54
     * @throws \Exception
55
     *
56
     * @return bool
57
     */
58 4
    public function isUserIdWhiteListed(): bool
59
    {
60 4
        return empty($this->findInListByRequestKey('user_id', $this->getShortClassName(), 'userId')) ? false : true;
61
    }
62
63
    /**
64
     * @throws \Exception
65
     *
66
     * @return bool
67
     */
68 6
    public function isEmailWhiteListed()
69
    {
70 6
        return $this->checkEmail();
71
    }
72
}
73