Completed
Pull Request — 2.x (#80)
by
unknown
02:00
created

NullSegment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 45
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 1
A get() 0 8 2
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\Auth\Session;
10
11
/**
12
 *
13
 * A $this->data segment; it attaches to $this->data lazily (i.e., only after a
14
 * session becomes available.)
15
 *
16
 * @package Aura.Auth
17
 *
18
 */
19
class NullSegment implements SegmentInterface
20
{
21
    /**
22
     *
23
     * The segment data.
24
     *
25
     * @var array
26
     *
27
     */
28
    protected $data = array();
29
30
    /**
31
     *
32
     * Gets a value from the segment.
33
     *
34
     * @param mixed $key A key for the segment value.
35
     *
36
     * @param mixed $alt Return this value if the segment key does not exist.
37
     *
38
     * @return mixed
39
     *
40
     */
41 1
    public function get($key, $alt = null)
42
    {
43 1
        if (isset($this->data[$key])) {
44 1
            return $this->data[$key];
45
        }
46
47 1
        return $alt;
48
    }
49
50
    /**
51
     *
52
     * Sets a value in the segment.
53
     *
54
     * @param mixed $key The key in the segment.
55
     *
56
     * @param mixed $val The value to set.
57
     *
58
     */
59 1
    public function set($key, $val)
60
    {
61 1
        $this->data[$key] = $val;
62 1
    }
63
}
64