Test Failed
Push — master ( afd99a...0309cf )
by Ilya
03:13
created

SessionMessagesStorage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getKey() 0 3 1
A get() 0 3 1
A put() 0 3 1
A setKey() 0 3 1
1
<?php
2
3
namespace Coderello\Laraflash\MessagesStorage;
4
5
use Illuminate\Contracts\Session\Session;
6
7
class SessionMessagesStorage implements MessagesStorageContract
8
{
9
    protected $session;
10
11
    protected $key;
12
13
    public function __construct(Session $session)
14
    {
15
        $this->session = $session;
16
    }
17
18
    public function setKey(string $key)
19
    {
20
        $this->key = $key;
21
    }
22
23
    public function getKey()
24
    {
25
        return $this->key ?? 'flash_messages';
26
    }
27
28
    public function get(): array
29
    {
30
        return $this->session->get($this->getKey(), []);
31
    }
32
33
    public function put(array $messages): void
34
    {
35
        $this->session->put($this->getKey(), $messages);
36
    }
37
}
38