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 = array()) |
|
50 | { |
||
51 | 9 | $this->name = $name; |
|
52 | 9 | $this->setValue($value); |
|
53 | 9 | $this->parameterBag = new ParameterBag($params); |
|
54 | 9 | } |
|
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 | //@todo added check for $this->parameterBag because doctrine/orm proxies won't execute constructor - ok? |
||
68 | 8 | if ($this->parameterBag && $this->parameterBag->hasParams()) { |
|
69 | 3 | $line .= ';' . $this->parameterBag->toString(); |
|
70 | 3 | } |
|
71 | |||
72 | // Property value |
||
73 | 8 | $line .= ':' . $this->value->getEscapedValue(); |
|
74 | |||
75 | 8 | return $line; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * Get all unfolded lines. |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | 4 | public function toLines() |
|
87 | |||
88 | /** |
||
89 | * @param string $name |
||
90 | * @param mixed $value |
||
91 | * |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function setParam($name, $value) |
||
100 | |||
101 | /** |
||
102 | * @param $name |
||
103 | */ |
||
104 | public function getParam($name) |
||
108 | |||
109 | /** |
||
110 | * @param mixed $value |
||
111 | * |
||
112 | * @return $this |
||
113 | * |
||
114 | * @throws \Exception |
||
115 | */ |
||
116 | 9 | public function setValue($value) |
|
132 | |||
133 | /** |
||
134 | * @return mixed |
||
135 | */ |
||
136 | public function getValue() |
||
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | 9 | public function getName() |
|
148 | } |
||
149 |