Passed
Push — master ( a569b2...1b7ab6 )
by Christian
03:49
created

ExistsTranslation::exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 6
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Omatech\Mage\Core\Repositories\Translations;
4
5
use Omatech\Mage\Core\Domains\Translations\Contracts\ExistsTranslationInterface;
6
use Omatech\Mage\Core\Domains\Translations\Contracts\TranslationInterface;
7
use Omatech\Mage\Core\Repositories\TranslationBaseRepository;
8
9
class ExistsTranslation extends TranslationBaseRepository implements ExistsTranslationInterface
10
{
11 15
    public function exists(TranslationInterface $translation): bool
12
    {
13 15
        return $this->query()
14
            ->where(static function ($q) use ($translation) {
15 15
                $q->where('group', $translation->getGroup())
16 15
                  ->where('key', $translation->getKey());
17 15
            })
18 15
            ->orWhere('id', $translation->getId())
19 15
            ->exists();
20
    }
21
}
22