ExistsAndDeleteTranslation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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