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

FindTranslation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 15
c 1
b 1
f 0
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 22 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 5
    public function find(string $key)
12
    {
13 5
        $translation = $this->query()
14 5
            ->where(DB::raw("CONCAT(`group`, '.', `key`)"), $key)
15 5
            ->first();
16
17 5
        if (null === $translation) {
18 3
            return app('mage.translations')::fromArray([
0 ignored issues
show
Bug introduced by
The method fromArray() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            return app('mage.translations')::/** @scrutinizer ignore-call */ fromArray([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19 3
                'key' => $key,
20
            ]);
21
        }
22
23 2
        $translation = app('mage.translations')::fromArray([
24 2
            'id'           => $translation->id,
25 2
            'key'          => $translation->group.'.'.$translation->key,
26 2
            'translations' => $translation->text,
27 2
            'sync_at'      => $translation->sync_at,
28 2
            'created_at'   => $translation->created_at,
29 2
            'updated_at'   => $translation->updated_at,
30
        ]);
31
32 2
        return $translation;
33
    }
34
}
35