BrowserDetectorDriver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A detect() 0 6 1
A chooseBestLanguage() 0 4 1
A browserLanguages() 0 4 1
1
<?php
2
3
namespace Vluzrmos\LanguageDetector\Drivers;
4
5
/**
6
 * Class BrowserDetectorDriver.
7
 */
8
class BrowserDetectorDriver extends AbstractDetector
9
{
10
    /**
11
     * Detect language.
12
     *
13
     * @return string|null Returns the detected locale or null.
14
     */
15
    public function detect()
16
    {
17
        $bestLanguage = $this->chooseBestLanguage();
18
19
        return $this->getAliasedLocale($bestLanguage);
20
    }
21
22
    /**
23
     * Get the best language between the browser and the application.
24
     *
25
     * @return string
26
     */
27
    public function chooseBestLanguage()
28
    {
29
        return $this->request->getPreferredLanguage($this->getLanguages());
30
    }
31
32
    /**
33
     * Get accept languages.
34
     *
35
     * @deprecated
36
     *
37
     * @return array
38
     */
39
    public function browserLanguages()
40
    {
41
        return $this->request->getLanguages();
42
    }
43
}
44