SessionSettingsStorage::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
nc 1
nop 0
crap 2
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