Completed
Push — master ( 79fd8a...81e819 )
by Christian
05:05
created

FindOrFailTranslation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 9 2
A __construct() 0 3 1
1
<?php
2
3
namespace Omatech\Mage\Core\Domains\Translations\Features;
4
5
use Omatech\Mage\Core\Domains\Translations\Translation;
6
use Omatech\Mage\Core\Domains\Translations\Jobs\FindTranslation;
7
use Omatech\Mage\Core\Domains\Translations\Exceptions\TranslationDoesNotExistsException;
8
9
class FindOrFailTranslation
10
{
11
    private $find;
12
13
    /**
14
     * FindOrFailTranslation constructor.
15
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
16
     */
17 2
    public function __construct()
18
    {
19 2
        $this->find = app()->make(FindTranslation::class);
20 2
    }
21
22
    /**
23
     * @param int $id
24
     * @return Translation
25
     * @throws TranslationDoesNotExistsException
26
     */
27 2
    public function make(int $id): Translation
28
    {
29 2
        $translation = $this->find->make($id);
30
31 2
        if ($translation === null) {
32 1
            throw new TranslationDoesNotExistsException;
33
        }
34
35 1
        return $translation;
36
    }
37
}
38