Passed
Push — master ( 4b44ca...bc88db )
by Stephen
03:38
created

RoleBuilder::whereNameIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
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 whereNameNot(string $name, string $boolean = 'and'): self
63
    {
64
        $this->whereName($name, '!=', $boolean);
65
66
        return $this;
67
    }
68
69
    /**
70
     * Scope query results to Role's with names that are in the array of $names.
71
     *
72
     * @param array $names
73
     * @param string $boolean
74
     * @param bool $not
75
     * @return $this
76
     */
77
    public function whereNameIn(array $names, string $boolean = 'and', bool $not = false): self
78
    {
79
        $this->whereIn('name', $names, $boolean, $not);
0 ignored issues
show
Bug introduced by
The method whereIn() does not exist on Sfneal\Users\Builders\RoleBuilder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

79
        $this->/** @scrutinizer ignore-call */ 
80
               whereIn('name', $names, $boolean, $not);
Loading history...
80
81
        return $this;
82
    }
83
84
    /**
85
     * Scope query results to Role's with names that are NOT in the array of $names.
86
     *
87
     * @param array $names
88
     * @param string $boolean
89
     * @return $this
90
     */
91
    public function whereNameNotIn(array $names, string $boolean = 'and'): self
92
    {
93
        $this->whereIn('name', $names, $boolean, true);
94
95
        return $this;
96
    }
97
}
98