FindSettingByKeyTask   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 10 2
1
<?php
2
3
namespace App\Containers\Settings\Tasks;
4
5
use App\Containers\Settings\Data\Repositories\SettingRepository;
6
use App\Ship\Exceptions\NotFoundException;
7
use App\Ship\Parents\Tasks\Task;
8
9
/**
10
 * Class FindSettingsByKeyTask
11
 *
12
 * @author  Mahmoud Zalt  <[email protected]>
13
 */
14
class FindSettingByKeyTask extends Task
15
{
16
17
    protected $repository;
18
19
    public function __construct(SettingRepository $repository)
20
    {
21
        $this->repository = $repository;
22
    }
23
24
    /**
25
     * @param $key
26
     *
27
     * @return mixed
28
     * @throws NotFoundException
29
     */
30
    public function run($key)
31
    {
32
        $result = $this->repository->findWhere(['key' => $key])->first();
33
34
        if (! $result) {
35
            throw new NotFoundException();
36
        }
37
38
        return $result->value;
39
    }
40
}
41