FlashMessageAware::addFlash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Controller;
6
7
use Symfony\Component\HttpFoundation\Session\Session;
8
9
trait FlashMessageAware
10
{
11
    /**
12
     * @var Session
13
     */
14
    protected $session;
15
16
    /**
17
     * Adds a flash message to the current session for type.
18
     *
19
     * @param string $severity ['success', 'notice', 'warning', 'error']
20
     * @param string $message
21
     */
22
    protected function addFlash($severity, $message)
23
    {
24
        $this->session->getFlashBag()->add($severity, $message);
25
    }
26
27
    /**
28
     * @return Session
29
     */
30
    public function getSession()
31
    {
32
        return $this->session;
33
    }
34
35
    /**
36
     * @param Session $session
37
     */
38
    public function setSession($session)
39
    {
40
        $this->session = $session;
41
    }
42
}
43