Oblist   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 2
A get() 0 4 2
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