Completed
Push — master ( c08cd6...da5e14 )
by Frédéric
09:00
created

Base::put()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CaribouFute\LocaleRoute\Session;
4
5
use Session;
6
7
abstract class Base
8
{
9
    protected $key;
10
11 5
    public function get()
12
    {
13 5
        return Session::get($this->key) ?: $this->setAndGetDefault();
14
    }
15
16 30
    public function set($value)
17
    {
18 30
        return $this->put($value);
19
    }
20
21 30
    public function put($value)
22
    {
23 30
        return Session::put($this->key, $value);
24
    }
25
26 2
    protected function setAndGetDefault()
27
    {
28 2
        $default = $this->getDefault();
29 2
        $this->set($default);
30 2
        return $default;
31
    }
32
33
    abstract protected function getDefault();
34
}
35