GetAllUsersTask   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 44
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 4 1
A clients() 0 4 1
A admins() 0 4 1
A ordered() 0 4 1
A withRole() 0 4 1
1
<?php
2
3
namespace App\Containers\User\Tasks;
4
5
use App\Containers\User\Data\Criterias\AdminsCriteria;
6
use App\Containers\User\Data\Criterias\ClientsCriteria;
7
use App\Containers\User\Data\Criterias\RoleCriteria;
8
use App\Containers\User\Data\Repositories\UserRepository;
9
use App\Ship\Criterias\Eloquent\OrderByCreationDateDescendingCriteria;
10
use App\Ship\Parents\Tasks\Task;
11
12
/**
13
 * Class GetAllUsersTask.
14
 *
15
 * @author Mahmoud Zalt <[email protected]>
16
 */
17
class GetAllUsersTask extends Task
18
{
19
20
    /**
21
     * @var  \App\Containers\User\Data\Repositories\UserRepository
22
     */
23
    protected $repository;
24
25
    /**
26
     * GetAllUsersTask constructor.
27
     *
28
     * @param \App\Containers\User\Data\Repositories\UserRepository $repository
29
     */
30
    public function __construct(UserRepository $repository)
31
    {
32
        $this->repository = $repository;
33
    }
34
35
    public function run()
36
    {
37
        return $this->repository->paginate();
38
    }
39
40
    public function clients()
41
    {
42
        $this->repository->pushCriteria(new ClientsCriteria());
43
    }
44
45
    public function admins()
46
    {
47
        $this->repository->pushCriteria(new AdminsCriteria());
48
    }
49
50
    public function ordered()
51
    {
52
        $this->repository->pushCriteria(new OrderByCreationDateDescendingCriteria());
53
    }
54
55
    public function withRole($roles)
56
    {
57
        $this->repository->pushCriteria(new RoleCriteria($roles));
58
    }
59
60
}
61