Message::setOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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