Base   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 10
c 1
b 0
f 0
dl 0
loc 33
ccs 12
cts 12
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 2
A __construct() 0 3 1
A setAndGetDefault() 0 5 1
A put() 0 3 1
A set() 0 3 1
1
<?php
2
3
namespace CaribouFute\LocaleRoute\Session;
4
5
use Illuminate\Session\Store;
6
7
abstract class Base
8
{
9
    protected $store;
10
    protected $key;
11
12 33
    public function __construct(Store $store)
13
    {
14 33
        $this->store = $store;
15
    }
16
17 5
    public function get()
18
    {
19 5
        return $this->store->get($this->key) ?: $this->setAndGetDefault();
20
    }
21
22 32
    public function set($value): void
23
    {
24 32
        $this->put($value);
25
    }
26
27 32
    public function put($value): void
28
    {
29 32
        $this->store->put($this->key, $value);
30
    }
31
32 2
    protected function setAndGetDefault()
33
    {
34 2
        $default = $this->getDefault();
35 2
        $this->set($default);
36 2
        return $default;
37
    }
38
39
    abstract protected function getDefault();
40
}
41