Map   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A get() 0 4 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 \CHMLib\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 \CHMLib\CHM|null
42
     */
43 1
    public function get($name)
44
    {
45 1
        return isset($this->map[$name]) ? $this->map[$name] : null;
46
    }
47
}
48