SessionMessagesStorage::put()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 3
    public function __construct(Session $session)
14
    {
15 3
        $this->session = $session;
16
    }
17
18 2
    public function setKey(string $key)
19
    {
20 2
        $this->key = $key;
21
    }
22
23 3
    public function getKey()
24
    {
25 3
        return $this->key ?? 'flash_messages';
26
    }
27
28
    public function get(): array
29
    {
30
        return $this->session->get($this->getKey(), []);
31
    }
32
33 1
    public function put(array $messages): void
34
    {
35 1
        $this->session->put($this->getKey(), $messages);
36
    }
37
}
38