FindTranslation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 23 2
1
<?php
2
3
namespace Omatech\Mage\Core\Repositories\Translations;
4
5
use Illuminate\Support\Facades\DB;
6
use Omatech\Mage\Core\Domains\Translations\Contracts\FindTranslationInterface;
7
use Omatech\Mage\Core\Repositories\TranslationBaseRepository;
8
9
class FindTranslation extends TranslationBaseRepository implements FindTranslationInterface
10
{
11
    /**
12
     * @param array $params
13
     * @return mixed
14
     */
15 9
    public function find(array $params)
16
    {
17 9
        $translation = $this->query()
18 9
            ->where(DB::raw("CONCAT(`group`, '.', `key`)"), $params['key'])
19 9
            ->first();
20
21 9
        if (null === $translation) {
22 8
            return app('mage.translations')::fromArray([
23 8
                'key' => $params['key'],
24
            ]);
25
        }
26
27 3
        $translation = app('mage.translations')::fromArray([
28 3
            'id'           => $translation->id,
29 3
            'key'          => $translation->group.'.'.$translation->key,
30 3
            'translations' => $translation->text,
31 3
            'sync_at'      => $translation->sync_at,
32 3
            'created_at'   => $translation->created_at,
33 3
            'updated_at'   => $translation->updated_at,
34
        ]);
35
36 3
        return $translation;
37
    }
38
}
39