1 | <?php |
||
23 | class Property |
||
24 | { |
||
25 | /** |
||
26 | * The value of the Property. |
||
27 | * |
||
28 | * @var ValueInterface |
||
29 | */ |
||
30 | protected $value; |
||
31 | |||
32 | /** |
||
33 | * The params of the Property. |
||
34 | * |
||
35 | * @var ParameterBag |
||
36 | */ |
||
37 | protected $parameterBag; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $name; |
||
43 | |||
44 | /** |
||
45 | * @param $name |
||
46 | * @param $value |
||
47 | * @param array $params |
||
48 | */ |
||
49 | 9 | public function __construct($name, $value, $params = []) |
|
55 | |||
56 | /** |
||
57 | * Renders an unfolded line. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 8 | public function toLine() |
|
62 | { |
||
63 | // Property-name |
||
64 | 8 | $line = $this->getName(); |
|
65 | |||
66 | // Adding params |
||
67 | 8 | if ($this->parameterBag->hasParams()) { |
|
68 | 3 | $line .= ';' . $this->parameterBag->toString(); |
|
69 | 3 | } |
|
70 | |||
71 | // Property value |
||
72 | 8 | $line .= ':' . $this->value->getEscapedValue(); |
|
73 | |||
74 | 8 | return $line; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Get all unfolded lines. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | 4 | public function toLines() |
|
86 | |||
87 | /** |
||
88 | * @param $value |
||
89 | * |
||
90 | * @return $this |
||
91 | * |
||
92 | * @throws \InvalidArgumentException |
||
93 | */ |
||
94 | 9 | protected function setValue($value) |
|
107 | |||
108 | /** |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function getValue() |
||
115 | |||
116 | /** |
||
117 | * @return string |
||
118 | */ |
||
119 | 9 | public function getName() |
|
123 | } |
||
124 |