SessionMessagesStorage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 29
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 3 1
A setKey() 0 3 1
A __construct() 0 3 1
A get() 0 3 1
A put() 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 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