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

NullSegment::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 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