Passed
Push — master ( cf0676...2847ea )
by Stephen
14:49 queued 11:55
created

RoleBuilder::whereNotName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sfneal\Users\Builders;
4
5
use Sfneal\Builders\QueryBuilder;
6
7
class RoleBuilder extends QueryBuilder
8
{
9
    /**
10
     * Scope Role query to roles of a particular type.
11
     *
12
     * @param string $type
13
     * @param string $operator
14
     * @param string $boolean
15
     *
16
     * @return $this
17
     */
18
    public function whereType(string $type, string $operator = '=', string $boolean = 'and')
19
    {
20
        $this->where('type', $operator, $type, $boolean);
21
22
        return $this;
23
    }
24
25
    /**
26
     * Scope Role query to only 'user' type roles.
27
     *
28
     * @param string $operator
29
     * @param string $boolean
30
     *
31
     * @return $this
32
     */
33
    public function whereTypeUser(string $operator = '=', string $boolean = 'and')
34
    {
35
        $this->whereType('user', $operator, $boolean);
36
37
        return $this;
38
    }
39
40
    /**
41
     * Scope query results to Role's matching a role 'name'.
42
     *
43
     * @param string $name
44
     * @param string $operator
45
     * @param string $boolean
46
     * @return $this
47
     */
48
    public function whereName(string $name, string $operator = '=', string $boolean = 'and'): self
49
    {
50
        $this->where('name', $operator, ucwords($name), $boolean);
51
52
        return $this;
53
    }
54
55
    /**
56
     * Scope query results to Role's that do NOT have a particular role 'name'.
57
     *
58
     * @param string $name
59
     * @param string $boolean
60
     * @return $this
61
     */
62
    public function whereNotName(string $name, string $boolean = 'and'): self
63
    {
64
        $this->whereName($name, '!=', $boolean);
65
        return $this;
66
    }
67
}
68