Completed
Push — master ( 857394...4794c5 )
by Mahmoud
03:25
created

FindApplicationByIdTask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 11 2
1
<?php
2
3
namespace App\Containers\Application\Tasks;
4
5
use App\Containers\Application\Data\Repositories\ApplicationRepository;
6
use App\Containers\Application\Exceptions\ApplicationNotFoundException;
7
use App\Port\Task\Abstracts\Task;
8
use Exception;
9
10
/**
11
 * Class FindApplicationByIdTask.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class FindApplicationByIdTask extends Task
16
{
17
18
    /**
19
     * @var  \App\Containers\Application\Data\Repositories\ApplicationRepository
20
     */
21
    private $applicationRepository;
22
23
    /**
24
     * FindApplicationByIdTask constructor.
25
     *
26
     * @param \App\Containers\Application\Data\Repositories\ApplicationRepository $applicationRepository
27
     */
28
    public function __construct(ApplicationRepository $applicationRepository)
29
    {
30
        $this->applicationRepository = $applicationRepository;
31
    }
32
33
    /**
34
     * @param $applicationId
35
     *
36
     * @return  mixed
37
     * @throws \App\Containers\Application\Exceptions\ApplicationNotFoundException
38
     */
39
    public function run($applicationId)
40
    {
41
        // find the application by its id
42
        try {
43
            $application = $this->applicationRepository->find($applicationId);
44
        } catch (Exception $e) {
45
            throw new ApplicationNotFoundException();
46
        }
47
48
        return $application;
49
    }
50
51
}
52