Completed
Push — master ( 812692...5d2ed7 )
by Ivan
07:38
created

SessionDetector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 25
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A detect() 0 6 1
A shouldValidate() 0 4 1
1
<?php
2
3
namespace CodeZero\Localizer\Detectors;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Support\Facades\Session;
7
8
class SessionDetector implements Detector
9
{
10
    /**
11
     * Detect the locale.
12
     *
13
     * @return string|array|null
14
     */
15 5
    public function detect()
16
    {
17 5
        $key = Config::get('localizer.session-key');
18
19 5
        return Session::get($key);
20
    }
21
22
    /**
23
     * Should the detected locale be validated
24
     * as a supported locale?
25
     *
26
     * @return bool
27
     */
28 1
    public function shouldValidate()
29
    {
30 1
        return true;
31
    }
32
}
33