Completed
Push — master ( 6d13cc...4d6b90 )
by Mahmoud
03:30
created

FindUserService::__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\Services;
4
5
use App\Containers\User\Contracts\UserRepositoryInterface;
6
use App\Containers\User\Exceptions\UserNotFoundException;
7
use App\Port\Service\Abstracts\Service;
8
use Exception;
9
10
/**
11
 * Class FindUserService.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class FindUserService extends Service
16
{
17
18
    /**
19
     * @var \App\Containers\User\Contracts\UserRepositoryInterface
20
     */
21
    private $userRepository;
22
23
    /**
24
     * FindUserService constructor.
25
     *
26
     * @param \App\Containers\User\Contracts\UserRepositoryInterface $userRepository
27
     */
28
    public function __construct(UserRepositoryInterface $userRepository)
29
    {
30
        $this->userRepository = $userRepository;
31
    }
32
33
    /**
34
     * @param            $email
35
     * @param            $password
36
     * @param            $name
37
     * @param bool|false $login
0 ignored issues
show
Bug introduced by
There is no parameter named $login. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
38
     *
39
     * @return  mixed
40
     */
41
    public function byId($id)
42
    {
43
        try {
44
            // find the user by its id
45
            $user = $this->userRepository->find($id);
46
        } catch (Exception $e) {
47
            throw new UserNotFoundException;
48
        }
49
50
        return $user;
51
    }
52
53
    /**
54
     * @param $agentId
55
     *
56
     * @return  mixed
57
     */
58
    public function byAgentId($agentId)
59
    {
60
        $user = $this->userRepository->findByField('agent_id', $agentId)->first();
61
62
        return $user;
63
    }
64
}
65