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

SessionMessagesStorage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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