BrowserLocaleServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A registerBrowserLocale() 0 5 1
1
<?php
2
3
namespace CodeZero\BrowserLocale\Laravel;
4
5
use CodeZero\BrowserLocale\BrowserLocale;
6
use Illuminate\Support\ServiceProvider;
7
use Request;
8
9
class BrowserLocaleServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Register any application services.
13
     *
14
     * @return void
15
     */
16
    public function register()
17
    {
18
        $this->registerBrowserLocale();
19
    }
20
21
    /**
22
     * Register BrowserLocale.
23
     *
24
     * @return void
25
     */
26
    protected function registerBrowserLocale()
27
    {
28
        $this->app->bind(BrowserLocale::class, function () {
29
            return new BrowserLocale(
30
                Request::server('HTTP_ACCEPT_LANGUAGE')
0 ignored issues
show
Bug introduced by
It seems like Request::server('HTTP_ACCEPT_LANGUAGE') can also be of type array; however, parameter $httpAcceptLanguages of CodeZero\BrowserLocale\B...erLocale::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

30
                /** @scrutinizer ignore-type */ Request::server('HTTP_ACCEPT_LANGUAGE')
Loading history...
31
            );
32
        });
33
    }
34
}
35