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

FindApplicationByIdTask::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
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