Completed
Push — master ( 150fd1...9bb841 )
by Mahmoud
06:22
created

FindSocialUserTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 7 1
1
<?php
2
3
namespace App\Containers\SocialAuth\Tasks;
4
5
use App\Containers\Authentication\Exceptions\MissingSocialIdException;
6
use App\Containers\User\Contracts\UserRepositoryInterface;
7
use App\Port\Task\Abstracts\Task;
8
9
/**
10
 * Class FindSocialUserTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class FindSocialUserTask extends Task
15
{
16
17
    /**
18
     * @var \App\Containers\User\Contracts\UserRepositoryInterface
19
     */
20
    private $userRepository;
21
22
    /**
23
     * FindSocialUserTask constructor.
24
     *
25
     * @param \App\Containers\User\Contracts\UserRepositoryInterface $userRepository
26
     */
27
    public function __construct(UserRepositoryInterface $userRepository)
28
    {
29
        $this->userRepository = $userRepository;
30
    }
31
32
    /**
33
     * @param $socialProvider
34
     * @param $socialId
35
     *
36
     * @return  mixed
37
     */
38
    public function run($socialProvider, $socialId)
39
    {
40
        return $this->userRepository->findWhere([
41
            'social_provider' => $socialProvider,
42
            'social_id'       => $socialId,
43
        ])->first();
44
    }
45
46
}
47