Completed
Push — master ( 783142...d739c9 )
by Nicolas
04:08 queued 48s
created

Translator::shouldRebuildCache()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 17
rs 8.8571
cc 5
eloc 10
nc 5
nop 1
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
        return parent::get($key, $replace, $locale);
25
    }
26
}
27