Oblist::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 2
rs 10
c 2
b 1
f 0
1
<?php
2
3
/**
4
 * @file
5
 * Oblist type.
6
 */
7
8
namespace Itafroma\Zork\State;
9
10
use Itafroma\Zork\Exception\OblistAtomExistsException;
11
12
class Oblist extends AbstractCollection
13
{
14
    /**
15
     * Creates an atom within the oblist with a null value.
16
     *
17
     * @param string $pname The name of the atom to create.
18
     * @return mixed The value of the atom created.
19
     */
20 2
    public function create($pname)
21
    {
22 2
        if (!isset($this->atoms[$pname])) {
23 1
            $this->atoms[$pname] = null;
24 1
        }
25
26 2
        return $this->atoms[$pname];
27
    }
28
29
    /**
30
     * Retrieves a value from the oblist.
31
     *
32
     * @param string $pname The name of the atom from which to retrieve the value.
33
     * @return mixed The value if the atom exists in the oblist, false otherwise.
34
     */
35 2
    public function get($pname)
36
    {
37 2
        return isset($this->atoms[$pname]) ? $this->atoms[$pname] : false;
38
    }
39
}
40