ExistsAndDeleteTranslation::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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