Passed
Push — master ( 848351...70e8d0 )
by
unknown
07:56 queued 01:57
created

Translations::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 33
rs 9.7333
cc 2
nc 2
nop 1
1
<?php namespace App\Listeners;
2
3
use Anomaly\Streams\Platform\Event\Booted;
4
use App\Lang\Loader;
5
use Illuminate\Translation\Translator;
6
7
class Translations
8
{
9
10
    public function handle(Booted $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

10
    public function handle(/** @scrutinizer ignore-unused */ Booted $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
11
    {
12
        app()->singleton(
13
            'translation.loader',
14
            function ($application) {
15
                return new Loader($application['files'], $application['path.lang']);
16
            }
17
        );
18
19
        app()->singleton(
20
            'translator',
21
            function ($application) {
22
                $loader = $application->make('translation.loader');
23
24
                // When registering the translator component, we'll need to set the default
25
                // locale as well as the fallback locale. So, we'll grab the application
26
                // configuration so we can easily get both of these values from there.
27
                $locale = $application['config']['app.locale'];
28
29
                $trans = new Translator($loader, $locale);
30
31
                $trans->setFallback($application['config']['app.fallback_locale']);
32
33
                return $trans;
34
            }
35
        );
36
37
        if (defined('LOCALE')) {
38
            app()->setLocale(LOCALE);
0 ignored issues
show
introduced by
The method setLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

38
            app()->/** @scrutinizer ignore-call */ setLocale(LOCALE);
Loading history...
39
            config()->set('app.locale', LOCALE);
40
        }
41
        // Set our locale namespace.
42
        app()->make('translator')->addNamespace('streams', realpath(__DIR__ . '/../../vendor/visiosoft/streams-platform/resources/lang'));
43
44
    }
45
}
46