Completed
Branch master (96e61a)
by Yann
02:18
created
src/Converters/Model/AbstractConverter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@
 block discarded – undo
20 20
 	 * @return mixed : The result of the conversion.
21 21
 	 */
22 22
 	public function convert($data, $options = []) {
23
-		if(!is_string($data) && !($data instanceof Document)) {
23
+		if (!is_string($data) && !($data instanceof Document)) {
24 24
 			throw new InvalidArgumentException('The $data variable must be of type "string" (the file path), or an instance of "Document".');
25 25
 		}
26
-		elseif(!is_array($options)) {
26
+		elseif (!is_array($options)) {
27 27
 			throw new InvalidArgumentException('The $options variable must be and array.');
28 28
 		}
29 29
 		
30
-		if(is_string($data)) {
30
+		if (is_string($data)) {
31 31
 			$parser = Parser::getInstance();
32 32
 			$data = $parser->buildDocumentTreeFromFilePath($data);	
33 33
 		}
Please login to merge, or discard this patch.
src/Converters/HTML/GenericHTMLConverter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			]);
85 85
 		$domElementB = $this->buildElement($document, $options[HTML_CONVERTER_MAIN_TAG_KEY][1]);
86 86
 		
87
-		if(!empty($node->getIcon()) && $options[HTML_CONVERTER_MAIN_ICON_KEY]) {
87
+		if (!empty($node->getIcon()) && $options[HTML_CONVERTER_MAIN_ICON_KEY]) {
88 88
 			$icon = $node->getIcon();
89 89
 			$domElementImg = $document->createElement('img');
90 90
 			$domElementImg->setAttribute('src', $icon->getFilePath());
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		}
94 94
 		
95 95
 		$text = $document->createTextNode($node->getText());
96
-		if(isset($options[HTML_CONVERTER_MAIN_TAG_KEY][2])) {
96
+		if (isset($options[HTML_CONVERTER_MAIN_TAG_KEY][2])) {
97 97
 			$domElementC = $this->buildElement($document, $options[HTML_CONVERTER_MAIN_TAG_KEY][2]);
98 98
 			$domElementC->appendChild($text);
99 99
 			$domElementB->appendChild($domElementC);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		
105 105
 		$domElementA->appendChild($domElementB);
106 106
 		
107
-		foreach($node->getChildren() as $child) {
107
+		foreach ($node->getChildren() as $child) {
108 108
 			$domElementB->appendChild($this->buildHTMLTreeFromNode($document, $child, $options));
109 109
 		}
110 110
 		
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	private function buildElement(DOMDocument $document, array $description) {
123 123
 		$domElement = $document->createElement($description[HTML_CONVERTER_TAG_KEY]);
124
-		foreach($description[HTML_CONVERTER_ATTRIBUTES_KEY] as $name => $attribute) {
124
+		foreach ($description[HTML_CONVERTER_ATTRIBUTES_KEY] as $name => $attribute) {
125 125
 			$domElement->setAttribute($name, $attribute);
126 126
 		}
127 127
 		
Please login to merge, or discard this patch.
src/Parser.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return Document : The document instance with all its nodes instances.
63 63
 	 */
64 64
 	public function buildDocumentTreeFromFilePath($filePath) {
65
-		if(!file_exists($filePath)) {
65
+		if (!file_exists($filePath)) {
66 66
 			throw new InvalidArgumentException('The given path : "'.$filePath.'" is invalid.');
67 67
 		}
68 68
 		
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	private function fillNode(DOMElement $domNode) {
86 86
 		//The given node name must be self::NODE_NODENAME
87
-		if($domNode->nodeName !== self::NODE_NODENAME) {
87
+		if ($domNode->nodeName !== self::NODE_NODENAME) {
88 88
 			throw new InvalidNodeNameException('The node name must be "node". "'.$domNode->nodeName.'" given.');
89 89
 		}
90 90
 		
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 		
95 95
 		//Build the list of children nodes and fill font information.
96 96
 		$children = new NodeList();
97
-		foreach($domNode->childNodes as $childNode) {
98
-			if($childNode->nodeName === self::NODE_NODENAME) {
97
+		foreach ($domNode->childNodes as $childNode) {
98
+			if ($childNode->nodeName === self::NODE_NODENAME) {
99 99
 				$children->add($this->fillNode($childNode));
100 100
 			}
101
-			elseif($childNode->nodeName === self::FONT_NODENAME) {
101
+			elseif ($childNode->nodeName === self::FONT_NODENAME) {
102 102
 				$this->fillNodeAttributes($childNode->attributes, self::$fontAvailableAttributes, $node);
103 103
 			}
104
-			elseif($childNode->nodeName === self::ICON_NODENAME) {
105
-				foreach($childNode->attributes as $attribute) {
106
-					if(array_key_exists($attribute->nodeName, self::$iconAvailableAttributes)) {
104
+			elseif ($childNode->nodeName === self::ICON_NODENAME) {
105
+				foreach ($childNode->attributes as $attribute) {
106
+					if (array_key_exists($attribute->nodeName, self::$iconAvailableAttributes)) {
107 107
 						$node->setIcon(new Icon($attribute->nodeValue));
108 108
 					}
109 109
 				}
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @param array $availableAttributes : One of the static array of this class to describe the list of known attributes.
123 123
 	 * @param Node $node : The Node object to fill in.
124 124
 	 */
125
-	private function fillNodeAttributes (DOMNamedNodeMap $nodeAtributes, array $availableAttributes, Node $node) {
126
-		foreach($nodeAtributes as $attribute) {
127
-			if(array_key_exists($attribute->nodeName, $availableAttributes)) {
125
+	private function fillNodeAttributes(DOMNamedNodeMap $nodeAtributes, array $availableAttributes, Node $node) {
126
+		foreach ($nodeAtributes as $attribute) {
127
+			if (array_key_exists($attribute->nodeName, $availableAttributes)) {
128 128
 				call_user_func([
129 129
 						$node, 
130 130
 						sprintf('openMindParser\Models\Node::set%s', ucfirst($availableAttributes[$attribute->nodeName]))
Please login to merge, or discard this patch.
src/Models/Node.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -357,23 +357,23 @@
 block discarded – undo
357 357
 	public function toArray() {
358 358
 		$array = [];
359 359
 		$sorter = function($value, $key) use(&$array) {
360
-			if($value instanceof NodeList) {
360
+			if ($value instanceof NodeList) {
361 361
 				$newValue = [];
362
-				foreach($value as $node) {
362
+				foreach ($value as $node) {
363 363
 					$newValue[] = $node->toArray();
364 364
 				}
365 365
 				$value = $newValue;
366 366
 			}
367
-			elseif($value instanceof Icon) {
367
+			elseif ($value instanceof Icon) {
368 368
 				$value = $value->getFilePath();
369 369
 			}
370
-			elseif($value instanceof DOMElement) {
370
+			elseif ($value instanceof DOMElement) {
371 371
 				return;
372 372
 			}
373 373
 			$array[$key] = $value;
374 374
 		};
375 375
 		
376
-		foreach(get_object_vars($this) as $key => $value) {
376
+		foreach (get_object_vars($this) as $key => $value) {
377 377
 			$sorter($value, $key);
378 378
 		}
379 379
 		
Please login to merge, or discard this patch.
src/Models/NodeList.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
14 14
 	private $list;
15 15
 	
16 16
 	public function __construct(array $list = null) {
17
-		if(empty($list)) {
17
+		if (empty($list)) {
18 18
 			$list = [];
19 19
 		}
20 20
 		
21
-		foreach($list as $node) {
22
-			if(!($node instanceof Node)) {
21
+		foreach ($list as $node) {
22
+			if (!($node instanceof Node)) {
23 23
 				throw new InvalidArgumentException('The array must contain only Node objects. "'.get_class($node).'" given.');
24 24
 			}
25 25
 		}
Please login to merge, or discard this patch.
src/Models/Document.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -148,16 +148,16 @@
 block discarded – undo
148 148
 	public function toArray() {
149 149
 		$array = [];
150 150
 		$sorter = function($value, $key) use(&$array) {
151
-			if($value instanceof Node) {
151
+			if ($value instanceof Node) {
152 152
 				$value = $value->toArray();
153 153
 			}
154
-			elseif($value instanceof DOMDocument) {
154
+			elseif ($value instanceof DOMDocument) {
155 155
 				return;
156 156
 			}
157 157
 			$array[$key] = $value;
158 158
 		};
159 159
 		
160
-		foreach(get_object_vars($this) as $key => $value) {
160
+		foreach (get_object_vars($this) as $key => $value) {
161 161
 			$sorter($value, $key);
162 162
 		}
163 163
 		
Please login to merge, or discard this patch.
src/Models/Icon.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param String $extension : The extension of the icon file without the leading dot. If it is a builtin icon, then it is 'png'.
39 39
 	 */ 
40 40
 	public function __construct($name = null, $extension = null, $fullFilePath = null, $filePath = null, $size = null) {
41
-		if(!empty($name)) {
41
+		if (!empty($name)) {
42 42
 			$this->setIcon($name, $extension, $fullFilePath, $filePath, $size);
43 43
 		}
44 44
 	}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$this->fullFilePath = $fullFilePath ?: realpath(IMG_FULL_ROOT_DIR.$this->name.'.'.$this->extension);
60 60
 		$this->filePath = $filePath ?: IMG_ROOT_DIR.$this->name.'.'.$this->extension;
61 61
 		
62
-		if(!file_exists($this->fullFilePath)) {
62
+		if (!file_exists($this->fullFilePath)) {
63 63
 			throw new UnexistentFileException('The file '.$this->fullFilePath.' does not exist !');
64 64
 		}
65 65
 		
Please login to merge, or discard this patch.
src/Patterns/AbstractSingleton.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	}
25 25
 	
26 26
 	/*Bunch of protected magic methods that must not be called in a Singleton pattern.*/
27
-	protected function __construct(){}
28
-	protected function __clone(){}
29
-	protected function __wakeup(){}
27
+	protected function __construct() {}
28
+	protected function __clone() {}
29
+	protected function __wakeup() {}
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.