Completed
Push — master ( a1ee40...42cbd3 )
by Yann
01:55
created
src/Converters/HTML/GenericHTMLConverter.php 1 patch
Spacing   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		$domElementA = $this->buildElement($document, $options[self::MAIN_TAG_KEY][0]);
139 139
 		
140 140
 		//Merge font size and font family to add inside the second wrapping DOMElement.
141
-		if($options[self::MAIN_TAG_MERGE_STYLE]) {
141
+		if ($options[self::MAIN_TAG_MERGE_STYLE]) {
142 142
 			$options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY] = array_merge(
143 143
 				$options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY], 
144 144
 				[
@@ -156,19 +156,18 @@  discard block
 block discarded – undo
156 156
 		$domElementB = $this->buildElement($document, $options[self::MAIN_TAG_KEY][1]);
157 157
 		
158 158
 		//Set the icon in an img tag whom will be wrapped in the second DOMElement.
159
-		if(!empty($node->getIcon()) && $options[self::MAIN_ICON_KEY][self::DISPLAY_ICON_KEY]) {
159
+		if (!empty($node->getIcon()) && $options[self::MAIN_ICON_KEY][self::DISPLAY_ICON_KEY]) {
160 160
 			$icon = $node->getIcon();
161 161
 			$domElementImg = $document->createElement('img');
162 162
 			
163 163
 			$iconUri = $icon->getShortUri();
164
-			if(array_key_exists(self::PATH_ICON_KEY, $options[self::MAIN_ICON_KEY])) {
165
-				if(!is_callable($callback = $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::CALLBACK_PATH_ICON_KEY])) {
164
+			if (array_key_exists(self::PATH_ICON_KEY, $options[self::MAIN_ICON_KEY])) {
165
+				if (!is_callable($callback = $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::CALLBACK_PATH_ICON_KEY])) {
166 166
 					throw new InvalidArgumentException('The argument with the key "'.self::CALLBACK_PATH_ICON_KEY.'" (self::CALLBACK_PATH_ICON_KEY) must be a valid callback.');
167 167
 				}
168 168
 				
169 169
 				$callBackoptions = array_key_exists(self::OPTIONS_PATH_ICON_KEY, $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY]) ?
170
-					$options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::OPTIONS_PATH_ICON_KEY] :
171
-					null;
170
+					$options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::OPTIONS_PATH_ICON_KEY] : null;
172 171
 				
173 172
 				$iconUri = $callback($icon->getFullName(), $callBackoptions);
174 173
 			}
@@ -182,13 +181,13 @@  discard block
 block discarded – undo
182 181
 		$text = $document->createTextNode($node->getText());
183 182
 		
184 183
 		//Bold an italic in old HTML way in order not to spread it to all children.
185
-		if($options[self::MAIN_TAG_MERGE_DECORATION]) {
186
-			if($node->isBold()) {
184
+		if ($options[self::MAIN_TAG_MERGE_DECORATION]) {
185
+			if ($node->isBold()) {
187 186
 				$bTag = $document->createElement('b');
188 187
 				$bTag->appendChild($text);
189 188
 				$text = $bTag;
190 189
 			}
191
-			if($node->isItalic()) {
190
+			if ($node->isItalic()) {
192 191
 				$iTag = $document->createElement('i');
193 192
 				$iTag->appendChild($text);
194 193
 				$text = $iTag;
@@ -196,7 +195,7 @@  discard block
 block discarded – undo
196 195
 		}
197 196
 		
198 197
 		//Append text node (real one or the one already wrapped inside <b> and/or <i> tags)
199
-		if(isset($options[self::MAIN_TAG_KEY][2])) {
198
+		if (isset($options[self::MAIN_TAG_KEY][2])) {
200 199
 			$domElementC = $this->buildElement($document, $options[self::MAIN_TAG_KEY][2]);
201 200
 			$domElementC->appendChild($text);
202 201
 			$domElementB->appendChild($domElementC);
@@ -206,7 +205,7 @@  discard block
 block discarded – undo
206 205
 		
207 206
 		$domElementA->appendChild($domElementB);
208 207
 		
209
-		foreach($node->getChildren() as $child) {
208
+		foreach ($node->getChildren() as $child) {
210 209
 			$domElementB->appendChild($this->buildHTMLTreeFromNode($document, $child, $options));
211 210
 		}
212 211
 		
@@ -219,8 +218,8 @@  discard block
 block discarded – undo
219 218
 	 * @param array &$options : The options array passed as reference.
220 219
 	 */
221 220
 	private function fillOptionalOptions(array &$options) {
222
-		foreach([self::MAIN_TAG_MERGE_DECORATION, self::MAIN_TAG_MERGE_STYLE] as $key) {
223
-			if(!array_key_exists($key, $options) || !is_bool($options[$key])) {
221
+		foreach ([self::MAIN_TAG_MERGE_DECORATION, self::MAIN_TAG_MERGE_STYLE] as $key) {
222
+			if (!array_key_exists($key, $options) || !is_bool($options[$key])) {
224 223
 				$options[$key] = true;
225 224
 			}
226 225
 		}
@@ -236,7 +235,7 @@  discard block
 block discarded – undo
236 235
 	 */
237 236
 	private function buildElement(DOMDocument $document, array $description) {
238 237
 		$domElement = $document->createElement($description[self::TAG_KEY]);
239
-		foreach($description[self::ATTRIBUTES_KEY] as $name => $attribute) {
238
+		foreach ($description[self::ATTRIBUTES_KEY] as $name => $attribute) {
240 239
 			$domElement->setAttribute($name, $attribute);
241 240
 		}
242 241
 		
Please login to merge, or discard this patch.