Completed
Push — master ( 1b2d0a...89ea1a )
by Oscar
03:00
created

PhpSession   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A get() 0 4 2
A set() 0 4 1
1
<?php
2
3
namespace Psr7Middlewares\Storage;
4
5
use Psr7Middlewares\Middleware;
6
7
/**
8
 * Wrapper for PHP sessions
9
 */
10
class PhpSession implements StorageInterface
11
{
12
    protected $storage;
13
14
    public function __construct(array &$storage)
15
    {
16
        if (!isset($storage[Middleware::KEY])) {
17
            $storage[Middleware::KEY] = [];
18
        }
19
20
        $this->storage =& $storage[Middleware::KEY];
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function get($key)
27
    {
28
        return isset($this->storage[$key]) ? $this->storage[$key] : null;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function set($key, $value)
35
    {
36
        $this->storage[$key] = $value;
37
    }
38
}
39