Message   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 64
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setOptions() 0 4 1
A getId() 0 4 1
A getOptions() 0 13 2
1
<?php
2
3
namespace Yokai\MessengerBundle;
4
5
/**
6
 * @author Yann Eugoné <[email protected]>
7
 */
8
class Message
9
{
10
    /**
11
     * @var string
12
     */
13
    private $id;
14
15
    /**
16
     * @var array
17
     */
18
    private $defaults;
19
20
    /**
21
     * @var array
22
     */
23
    private $options;
24
25
    /**
26
     * @param string $id
27
     * @param array  $defaults
28
     */
29 14
    public function __construct($id, array $defaults = [])
30
    {
31 14
        $this->id = $id;
32 14
        $this->defaults = $defaults;
33 14
        $this->options = [];
34 14
    }
35
36
    /**
37
     * @param string $channel
38
     * @param array  $options
39
     */
40 1
    public function setOptions($channel, array $options)
41
    {
42 1
        $this->options[$channel] = $options;
43 1
    }
44
45
    /**
46
     * @return string
47
     */
48 13
    public function getId()
49
    {
50 13
        return $this->id;
51
    }
52
53
    /**
54
     * @param string $channel
55
     *
56
     * @return array
57
     */
58 10
    public function getOptions($channel)
59
    {
60 10
        $options = $this->defaults;
61
62 10
        if (isset($this->options[$channel])) {
63 1
            $options = array_merge(
64 1
                $options,
65 1
                $this->options[$channel]
66
            );
67
        }
68
69 10
        return $options;
70
    }
71
}
72