Translator::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 4
b 0
f 0
nc 2
nop 4
dl 0
loc 9
rs 9.6666
1
<?php namespace Modules\Translation\Services;
2
3
use Illuminate\Foundation\Bus\DispatchesJobs;
4
use Modules\Translation\Repositories\TranslationRepository;
5
6
class Translator extends \Illuminate\Translation\Translator
7
{
8
    use DispatchesJobs;
9
    /**
10
     * Get the translation for the given key.
11
     *
12
     * @param  string  $key
13
     * @param  array   $replace
14
     * @param  string  $locale
15
     * @param  bool  $fallback
16
     * @return string
17
     */
18
    public function get($key, array $replace = [], $locale = null, $fallback = true)
19
    {
20
        $translationRepository = app(TranslationRepository::class);
21
        if ($translation = $translationRepository->findByKeyAndLocale($key, $locale)) {
22
            return $this->makeReplacements($translation, $replace);
23
        }
24
25
        return parent::get($key, $replace, $locale);
26
    }
27
}
28