Completed
Push — master ( 2ee640...af544d )
by Mahmoud
04:57
created

CountUsersAction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Containers\User\Actions;
4
5
use App\Containers\User\Settings\Repositories\UserRepository;
6
use App\Port\Action\Abstracts\Action;
7
use App\Port\Criterias\Eloquent\IsNullCriteria;
8
use App\Port\Criterias\Eloquent\NotNullCriteria;
9
10
/**
11
 * Class CountUsersAction.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class CountUsersAction extends Action
16
{
17
18
    /**
19
     * CountUsersAction constructor.
20
     *
21
     * @param \App\Containers\User\Settings\Repositories\UserRepository $userRepository
22
     */
23
    public function __construct(UserRepository $userRepository)
24
    {
25
        $this->userRepository = $userRepository;
0 ignored issues
show
Bug introduced by
The property userRepository does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
    }
27
28
    /**
29
     * @return  mixed
30
     */
31
    public function all()
32
    {
33
        return $this->userRepository->all()->count();
34
    }
35
36
    /**
37
     * @return  mixed
38
     * @throws \Prettus\Repository\Exceptions\RepositoryException
39
     */
40
    public function visitors()
41
    {
42
        $this->userRepository->pushCriteria(new IsNullCriteria('email'));
43
44
        return $this->userRepository->all()->count();
45
    }
46
47
    /**
48
     * @return  mixed
49
     * @throws \Prettus\Repository\Exceptions\RepositoryException
50
     */
51
    public function registered()
52
    {
53
        $this->userRepository->pushCriteria(new NotNullCriteria('email'));
54
55
        return $this->userRepository->all()->count();
56
    }
57
58
}
59