Completed
Push — master ( 9157af...94c184 )
by Michele
04:14
created

Map::get()   A

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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace CHMLib;
4
5
/**
6
 * Map one or more CHM files to the parsed CHM instances.
7
 */
8
class Map
9
{
10
    /**
11
     * The map dictionary.
12
     *
13
     * @var array
14
     */
15
    protected $map;
16
17
    /**
18
     * Initializes the instance.
19
     */
20 1
    public function __construct()
21
    {
22 1
        $this->map = array();
23 1
    }
24
25
    /**
26
     * Add a parsed CHM file to this map.
27
     *
28
     * @param string $name The name to give the new CHM instance.
29
     * @param CHM $chm The parsed CHM file.
30
     */
31 1
    public function add($name, CHM $chm)
32
    {
33 1
        $this->map[$name] = $chm;
34 1
    }
35
36
    /**
37
     * Get a parsed CHM file given its name.
38
     *
39
     * @param string $name The mapped name.
40
     *
41
     * @return CHM|null
42
     */
43 1
    public function get($name)
44
    {
45 1
        return isset($this->map[$name]) ? $this->map[$name] : null;
46
    }
47
}
48