Passed
Push — master ( a160e4...413705 )
by Sergio
03:11 queued 01:07
created
src/Parsers/XMLParser.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 class XMLParser implements StreamParserInterface
19 19
 {
20
-	protected $reader,$source;
20
+	protected $reader, $source;
21 21
 
22 22
 	protected $skipFirstElement = true;
23 23
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return $this;
29 29
 	}
30 30
 
31
-	public function withoutSkippingFirstElement(){
31
+	public function withoutSkippingFirstElement() {
32 32
 		$this->skipFirstElement = false;
33 33
 
34 34
 		return $this;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function each(callable $function)
38 38
 	{
39 39
 		$this->start();
40
-		while($this->reader->read()){
40
+		while ($this->reader->read()) {
41 41
 			$this->searchElement($function);
42 42
 		}
43 43
 		$this->stop();
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 	private function searchElement(callable $function)
47 47
 	{
48
-		if($this->isElement() && ! $this->shouldBeSkipped()){
48
+		if ($this->isElement() && ! $this->shouldBeSkipped()) {
49 49
 			$function($this->extractElement($this->reader->name, false, $this->reader->depth));
50 50
 		}
51 51
 	}
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		$elementCollection = (new Collection())->merge($this->getCurrentElementAttributes());
56 56
 
57
-		if($this->isEmptyElement($elementName)) {
57
+		if ($this->isEmptyElement($elementName)) {
58 58
 			return $elementCollection;
59 59
 		}
60 60
 
61
-		while($this->reader->read()) {
62
-			if($this->isEndElement($elementName) && $this->reader->depth === $parentDepth) {
61
+		while ($this->reader->read()) {
62
+			if ($this->isEndElement($elementName) && $this->reader->depth === $parentDepth) {
63 63
 				break;
64 64
 			}
65
-			if($this->isValue()) {
66
-				if($elementCollection->isEmpty()) {
65
+			if ($this->isValue()) {
66
+				if ($elementCollection->isEmpty()) {
67 67
 					return trim($this->reader->value);
68 68
 				} else {
69 69
 					return $elementCollection->put($elementName, trim($this->reader->value));
70 70
 				}
71 71
 			}
72
-			if($this->isElement()) {
73
-				if($couldBeAnElementsList) {
72
+			if ($this->isElement()) {
73
+				if ($couldBeAnElementsList) {
74 74
 					$foundElementName = $this->reader->name;
75 75
 					$elementCollection->push(new Collection($this->extractElement($foundElementName, false, $this->reader->depth)));
76 76
 				} else {
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 		return $elementCollection;
84 84
 	}
85 85
 
86
-	private function getCurrentElementAttributes(){
86
+	private function getCurrentElementAttributes() {
87 87
 		$attributes = new Collection();
88
-		if($this->reader->hasAttributes)  {
89
-			while($this->reader->moveToNextAttribute()) {
88
+		if ($this->reader->hasAttributes) {
89
+			while ($this->reader->moveToNextAttribute()) {
90 90
 				$attributes->put($this->reader->name, $this->reader->value);
91 91
 			}
92 92
 		}
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 
104 104
 	private function stop()
105 105
 	{
106
-		if( ! $this->reader->close()){
106
+		if ( ! $this->reader->close()) {
107 107
 			throw new IncompleteParseException();
108 108
 		}
109 109
 	}
110 110
 
111
-	private function shouldBeSkipped(){
112
-		if($this->skipFirstElement){
111
+	private function shouldBeSkipped() {
112
+		if ($this->skipFirstElement) {
113 113
 			$this->skipFirstElement = false;
114 114
 			return true;
115 115
 		}
@@ -117,28 +117,28 @@  discard block
 block discarded – undo
117 117
 		return false;
118 118
 	}
119 119
 
120
-	private function isElement(String $elementName = null){
121
-		if($elementName){
120
+	private function isElement(String $elementName = null) {
121
+		if ($elementName) {
122 122
 			return $this->reader->nodeType == XMLReader::ELEMENT && $this->reader->name === $elementName;
123 123
 		} else {
124 124
 			return $this->reader->nodeType == XMLReader::ELEMENT;
125 125
 		}
126 126
 	}
127 127
 
128
-	private function isEndElement(String $elementName = null){
129
-		if($elementName){
128
+	private function isEndElement(String $elementName = null) {
129
+		if ($elementName) {
130 130
 			return $this->reader->nodeType == XMLReader::END_ELEMENT && $this->reader->name === $elementName;
131 131
 		} else {
132 132
 			return $this->reader->nodeType == XMLReader::END_ELEMENT;
133 133
 		}
134 134
 	}
135 135
 
136
-	private function isValue(){
136
+	private function isValue() {
137 137
 		return $this->reader->nodeType == XMLReader::TEXT || $this->reader->nodeType === XMLReader::CDATA;
138 138
 	}
139 139
 
140
-    private function isEmptyElement(String $elementName = null){
141
-	    if($elementName) {
140
+    private function isEmptyElement(String $elementName = null) {
141
+	    if ($elementName) {
142 142
 		    return $this->reader->isEmptyElement && $this->reader->name === $elementName;
143 143
 	    } else {
144 144
 		    return false;
Please login to merge, or discard this patch.