SessionSettingsStorage   A
last analyzed

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
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 24
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A get() 0 4 1
1
<?php
2
/**
3
 * Pluggable themes for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager\storage;
12
13
use Yii;
14
use yii\base\Component;
15
use yii\base\Model;
16
17
class SessionSettingsStorage extends Component implements SettingsStorageInterface
18
{
19
    /**
20
     * @var string
21
     */
22
    public $sessionKey = 'themeManger.themeSettings';
23
24
    /**
25
     * @param Model $model the settings model
26
     */
27
    public function set(Model $model)
28
    {
29
        $data = $model->toArray();
30
        Yii::$app->session->set($this->sessionKey, $data);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function get()
37
    {
38
        return Yii::$app->session->get($this->sessionKey);
39
    }
40
}
41