Completed
Push — master ( bed82d...5b1b17 )
by Dmitry
02:54
created

SessionSettingsStorage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A get() 0 4 1
1
<?php
2
3
namespace hiqdev\thememanager\storage;
4
5
use Yii;
6
use yii\base\Component;
7
use yii\base\Model;
8
9
class SessionSettingsStorage extends Component implements SettingsStorageInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    public $sessionKey = 'themeManger.themeSettings';
15
16
    /**
17
     * @param Model $model the settings model
18
     */
19
    public function set(Model $model)
20
    {
21
        $data = $model->toArray();
22
        Yii::$app->session->set($this->sessionKey, $data);
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function get()
29
    {
30
        return Yii::$app->session->get($this->sessionKey);
31
    }
32
}
33