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

ExistsAndDeleteTranslation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
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\DeleteTranslation;
7
use Omatech\Mage\Core\Domains\Translations\Jobs\ExistsTranslation;
8
use Omatech\Mage\Core\Domains\Translations\Exceptions\TranslationDoesNotExistsException;
9
10
class ExistsAndDeleteTranslation
11
{
12
    private $exists;
13
    private $delete;
14
15
    /**
16
     * ExistsAndDeleteTranslation constructor.
17
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
18
     */
19 3
    public function __construct()
20
    {
21 3
        $this->exists = app()->make(ExistsTranslation::class);
22 3
        $this->delete = app()->make(DeleteTranslation::class);
23 3
    }
24
25
    /**
26
     * @param Translation $translation
27
     * @return bool
28
     * @throws TranslationDoesNotExistsException
29
     */
30 3
    public function make(Translation $translation): bool
31
    {
32 3
        $exists = $this->exists->make($translation);
33
34 3
        if ($exists === false) {
35 1
            throw new TranslationDoesNotExistsException;
36
        }
37
38 3
        return $this->delete->make($translation);
39
    }
40
}
41