UserListQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 9
c 2
b 1
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A execute() 0 7 1
A builder() 0 3 1
1
<?php
2
3
namespace Sfneal\Users\Queries;
4
5
use Sfneal\Queries\Query;
6
use Sfneal\Users\Builders\UserBuilder;
7
use Sfneal\Users\Models\User;
8
9
class UserListQuery extends Query
10
{
11
    /**
12
     * @var string Query string containing portions of a User's name
13
     */
14
    private $nameQuery;
15
16
    /**
17
     * TeamListQuery constructor.
18
     *
19
     * @param  string  $nameQuery
20
     */
21
    public function __construct(string $nameQuery)
22
    {
23
        $this->nameQuery = $nameQuery;
24
    }
25
26
    /**
27
     * Retrieve a Query builder.
28
     *
29
     * @return UserBuilder
30
     */
31
    protected function builder(): UserBuilder
32
    {
33
        return User::query();
34
    }
35
36
    /**
37
     * Execute a Team ajax search.
38
     *
39
     * @return array
40
     */
41
    public function execute(): array
42
    {
43
        return $this->builder()
44
            ->whereNameLike($this->nameQuery)
45
            ->whereActive()
46
            ->selectRawJson()
47
            ->countAndPaginate();
48
    }
49
}
50