FlashTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A success() 0 3 1
A info() 0 3 1
A flash() 0 4 1
A error() 0 3 1
A warning() 0 3 1
1
<?php
2
/**
3
 * @link https://github.com/zhuravljov/yii2-queue-monitor
4
 * @copyright Copyright (c) 2017 Roman Zhuravlev
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
8
namespace zhuravljov\yii\queue\monitor\base;
9
10
use Yii;
11
12
/**
13
 * FlashTrait
14
 *
15
 * @author Roman Zhuravlev <[email protected]>
16
 */
17
trait FlashTrait
18
{
19
    /**
20
     * @param string $message
21
     * @return $this
22
     */
23
    protected function success($message)
24
    {
25
        return $this->flash('success', $message);
26
    }
27
28
    /**
29
     * @param string $message
30
     * @return $this
31
     */
32
    protected function info($message)
33
    {
34
        return $this->flash('info', $message);
35
    }
36
37
    /**
38
     * @param string $message
39
     * @return $this
40
     */
41
    protected function warning($message)
42
    {
43
        return $this->flash('warning', $message);
44
    }
45
46
    /**
47
     * @param string $message
48
     * @return $this
49
     */
50
    protected function error($message)
51
    {
52
        return $this->flash('error', $message);
53
    }
54
55
    /**
56
     * @param string $type
57
     * @param string $message
58
     * @return $this
59
     */
60
    protected function flash($type, $message)
61
    {
62
        Yii::$app->session->setFlash($type, $message);
0 ignored issues
show
Bug introduced by
The method setFlash() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

62
        Yii::$app->session->/** @scrutinizer ignore-call */ 
63
                            setFlash($type, $message);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
        return $this;
64
    }
65
}
66