Completed
Push — master ( ddfb7b...c3a867 )
by Michele
04:20
created

Map::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 6
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
    public function __construct()
21
    {
22
        $this->map = array();
23
    }
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
    public function add($name, CHM $chm)
32
    {
33
        $this->map[$name] = $chm;
34
    }
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
    public function get($name)
44
    {
45
        return isset($this->map[$name]) ? $this->map[$name] : null;
46
    }
47
}
48