Redis   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 80
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 6 1
A getFlash() 0 4 1
A getAllFlashes() 0 4 1
A hasFlash() 0 4 1
1
<?php
2
3
namespace flipbox\craft\session;
4
5
use craft\behaviors\SessionBehavior;
6
use yii\redis\Session;
7
8
class Redis extends Session
9
{
10
    // Public Methods
11
    // =========================================================================
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function behaviors()
17
    {
18
        return [
19
            SessionBehavior::class,
20
        ];
21
    }
22
23
    /**
24
     * @inheritdoc
25
     *
26
     * ---
27
     *
28
     * ```php
29
     * $message = Craft::$app->session->getFlash('notice', null, true);
30
     * ```
31
     * ```twig{1}
32
     * {% set message = craft.app.session.getFlash('notice', null, true) %}
33
     * {% if message %}
34
     *     <p class="notice">
35
     *         {{ message }}
36
     *     </p>
37
     * {% endif %}
38
     * ```
39
     */
40
    public function getFlash($key, $defaultValue = null, $delete = false)
41
    {
42
        return parent::getFlash($key, $defaultValue, $delete);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     *
48
     * ---
49
     *
50
     * ```php
51
     * $messages = Craft::$app->session->getAllFlashes(true);
52
     * ```
53
     * ```twig{1}
54
     * {% set messages = craft.app.session.getAllFLashes(true) %}
55
     * {% for key, message in messages %}
56
     *     <p class="{{ key }}">
57
     *         {{ message }}
58
     *     </p>
59
     * {% endfor %}
60
     * ```
61
     */
62
    public function getAllFlashes($delete = false)
63
    {
64
        return parent::getAllFlashes($delete);
65
    }
66
67
    /**
68
     * @inheritdoc
69
     *
70
     * ---
71
     *
72
     * ```php
73
     * $hasNotice = Craft::$app->session->hasFlash('notice');
74
     * ```
75
     * ```twig{1}
76
     * {% if craft.app.session.hasFlash('notice') %}
77
     *     <p class="notice">
78
     *         {{ craft.app.session.getFlash('notice', null, true) }}
79
     *     </p>
80
     * {% endif %}
81
     * ```
82
     */
83
    public function hasFlash($key)
84
    {
85
        return parent::hasFlash($key);
86
    }
87
}
88