Completed
Push — master ( df04fd...726a09 )
by
unknown
03:40
created

ParameterBag::setDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Handler;
4
5
class ParameterBag implements ParameterBagInterface
6
{
7
    /**
8
     * @var int
9
     */
10
    protected $id;
11
12
    /**
13
     * @var int
14
     */
15
    protected $width;
16
17
    /**
18
     * @var int
19
     */
20
    protected $height;
21
22
    /**
23
     * @var array
24
     */
25
    protected $extra = [];
26
27
    /**
28
     * @param int $id
29
     * @param int $width
30
     * @param int $height
31
     * @param array $extra
32
     */
33
    public function __construct($id, $width, $height, array $extra = [])
34
    {
35
        $this->id = $id;
36
        $this->width = $width;
37
        $this->height = $height;
38
        $this->extra = $extra;
39
    }
40
41
    /**
42
     * @return int
43
     */
44
    public function getId()
45
    {
46
        return $this->id;
47
    }
48
49
    /**
50
     * @return int
51
     */
52
    public function getWidth()
53
    {
54
        return $this->width;
55
    }
56
57
    /**
58
     * @return int
59
     */
60
    public function getHeight()
61
    {
62
        return $this->height;
63
    }
64
65
    /**
66
     * @return array
67
     */
68
    public function getExtra()
69
    {
70
        return $this->extra;
71
    }
72
73
    /**
74
     * @param array $defaults
75
     */
76
    public function setDefaults(array $defaults)
77
    {
78
        $this->extra = array_merge($defaults, $this->extra);
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function toArray()
85
    {
86
        return array_merge($this->getExtra(), [
87
            'id' => $this->getId(),
88
            'width' => $this->getWidth(),
89
            'height' => $this->getHeight(),
90
        ]);
91
    }
92
}
93