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

FindOrFailTranslation::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
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