Passed
Push — master ( 1ed9d2...698c63 )
by Sergio
01:13
created
src/Parsers/XMLParser.php 1 patch
Spacing   +21 added lines, -21 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));
50 50
 		}
51 51
 	}
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		$elementCollection = (new Collection())->merge($this->getCurrentElementAttributes());
56 56
 
57
-		while($this->reader->read()){
58
-			if($this->isEndElement($elementName)){
57
+		while ($this->reader->read()) {
58
+			if ($this->isEndElement($elementName)) {
59 59
 				break;
60 60
 			}
61
-			if($this->isValue()){
62
-				if($elementCollection->isEmpty()){
61
+			if ($this->isValue()) {
62
+				if ($elementCollection->isEmpty()) {
63 63
 					return trim($this->reader->value);
64 64
 				} else {
65 65
 					return $elementCollection->put($elementName, trim($this->reader->value));
66 66
 				}
67 67
 			}
68
-			if($this->isElement()){
69
-				if($couldBeAnElementsList){
68
+			if ($this->isElement()) {
69
+				if ($couldBeAnElementsList) {
70 70
 					$foundElementName = $this->reader->name;
71 71
 					$elementCollection->push(new Collection($this->extractElement($foundElementName)));
72 72
 				} else {
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 		return $elementCollection;
80 80
 	}
81 81
 
82
-	private function getCurrentElementAttributes(){
82
+	private function getCurrentElementAttributes() {
83 83
 		$attributes = new Collection();
84
-		if($this->reader->hasAttributes)  {
85
-			while($this->reader->moveToNextAttribute()) {
84
+		if ($this->reader->hasAttributes) {
85
+			while ($this->reader->moveToNextAttribute()) {
86 86
 				$attributes->put($this->reader->name, $this->reader->value);
87 87
 			}
88 88
 		}
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 
100 100
 	private function stop()
101 101
 	{
102
-		if( ! $this->reader->close()){
102
+		if ( ! $this->reader->close()) {
103 103
 			throw new IncompleteParseException();
104 104
 		}
105 105
 	}
106 106
 
107
-	private function shouldBeSkipped(){
108
-		if($this->skipFirstElement){
107
+	private function shouldBeSkipped() {
108
+		if ($this->skipFirstElement) {
109 109
 			$this->skipFirstElement = false;
110 110
 			return true;
111 111
 		}
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 		return false;
114 114
 	}
115 115
 
116
-	private function isElement(String $elementName = null){
117
-		if($elementName){
116
+	private function isElement(String $elementName = null) {
117
+		if ($elementName) {
118 118
 			return $this->reader->nodeType == XMLReader::ELEMENT && $this->reader->name === $elementName;
119 119
 		} else {
120 120
 			return $this->reader->nodeType == XMLReader::ELEMENT;
121 121
 		}
122 122
 	}
123 123
 
124
-	private function isEndElement(String $elementName = null){
125
-		if($elementName){
124
+	private function isEndElement(String $elementName = null) {
125
+		if ($elementName) {
126 126
 			return $this->reader->nodeType == XMLReader::END_ELEMENT && $this->reader->name === $elementName;
127 127
 		} else {
128 128
 			return $this->reader->nodeType == XMLReader::END_ELEMENT;
129 129
 		}
130 130
 	}
131 131
 
132
-	private function isValue(){
132
+	private function isValue() {
133 133
 		return $this->reader->nodeType == XMLReader::TEXT || $this->reader->nodeType === XMLReader::CDATA;
134 134
 	}
135 135
 }
Please login to merge, or discard this patch.
src/Services/JsonCollectionParser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			throw $e;
44 44
 		}
45 45
 
46
-		if( ! fclose($stream)){
46
+		if ( ! fclose($stream)) {
47 47
 			throw new IncompleteParseException();
48 48
 		}
49 49
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	{
59 59
 		$stream = @fopen($filePath, 'r');
60 60
 		if (false === $stream) {
61
-			throw new \Exception('Unable to open file for read: ' . $filePath);
61
+			throw new \Exception('Unable to open file for read: '.$filePath);
62 62
 		}
63 63
 
64 64
 		return $stream;
Please login to merge, or discard this patch.
src/Parsers/CSVParser.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 {
18 18
 	protected $reader, $source, $headers, $currentLine;
19 19
 
20
-	public static $delimiters = [",", ";"];
20
+	public static $delimiters = [ ",", ";" ];
21 21
 	public static $skipsEmptyLines = true;
22 22
 
23 23
 	public function from(String $source): StreamParserInterface
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	public function each(callable $function)
31 31
 	{
32 32
 		$this->start();
33
-		while($this->read()){
34
-			if($this->currentLineIsValid()){
33
+		while ($this->read()) {
34
+			if ($this->currentLineIsValid()) {
35 35
 				$function($this->getCurrentLineAsCollection());
36 36
 			}
37 37
 		}
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 		return $this;
49 49
 	}
50 50
 
51
-	private function close(){
52
-		if( ! fclose($this->reader)){
51
+	private function close() {
52
+		if ( ! fclose($this->reader)) {
53 53
 			throw new IncompleteParseException();
54 54
 		}
55 55
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	}
63 63
 
64 64
 	private function currentLineIsValid(): bool{
65
-		if(static::$skipsEmptyLines){
65
+		if (static::$skipsEmptyLines) {
66 66
 			return ! $this->currentLineIsEmpty();
67 67
 		}
68 68
 
69 69
 		return true;
70 70
 	}
71 71
 
72
-	private function currentLineIsEmpty(){
73
-		return $this->currentLine->reject(function($value){
72
+	private function currentLineIsEmpty() {
73
+		return $this->currentLine->reject(function($value) {
74 74
 			return $this->isEmptyValue($value);
75 75
 		})->isEmpty();
76 76
 	}
77 77
 
78
-	private function isEmptyValue($value){
78
+	private function isEmptyValue($value) {
79 79
 		return $value === "" || $value === null;
80 80
 	}
81 81
 
@@ -86,25 +86,25 @@  discard block
 block discarded – undo
86 86
 
87 87
 		return $headers->intersectByKeys($this->currentLine)
88 88
 			->combine($values->recursive())
89
-			->reject(function($value){
89
+			->reject(function($value) {
90 90
 				return $this->isEmptyValue($value);
91 91
 			});
92 92
 	}
93 93
 
94
-	private function formatCurrentLineValues(Collection $collection){
94
+	private function formatCurrentLineValues(Collection $collection) {
95 95
 		$this->explodeCollectionValues($collection);
96 96
 		return $collection;
97 97
 	}
98 98
 
99
-	private function explodeCollectionValues(Collection $collection){
100
-		$collection->transform(function($value){
99
+	private function explodeCollectionValues(Collection $collection) {
100
+		$collection->transform(function($value) {
101 101
 			(new Collection(static::$delimiters))->each(function($delimiter) use (&$value){
102
-				if( ! is_array($value) && strpos($value, $delimiter) !== false){
102
+				if ( ! is_array($value) && strpos($value, $delimiter) !== false) {
103 103
 					$value = explode($delimiter, $value);
104 104
 				}
105 105
 			});
106
-			if(is_array($value)){
107
-				return (new Collection($value))->reject(function($value){
106
+			if (is_array($value)) {
107
+				return (new Collection($value))->reject(function($value) {
108 108
 					return $this->isEmptyValue($value);
109 109
 				});
110 110
 			} else {
Please login to merge, or discard this patch.
src/StreamParser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private function __construct()
23 23
 	{
24
-		Collection::macro('recursive', function () {
25
-			return $this->map(function ($value) {
24
+		Collection::macro('recursive', function() {
25
+			return $this->map(function($value) {
26 26
 				if (is_array($value) || is_object($value)) {
27 27
 					return (new Collection($value))->recursive();
28 28
 				}
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
 		});
32 32
 	}
33 33
 
34
-	private function xml(String $source){
34
+	private function xml(String $source) {
35 35
 		return (new XMLParser())->from($source);
36 36
 	}
37 37
 
38
-	private function json(String $source){
38
+	private function json(String $source) {
39 39
 		return (new JSONParser())->from($source);
40 40
 	}
41 41
 
42
-	private function csv(String $source){
42
+	private function csv(String $source) {
43 43
 		return (new CSVParser())->from($source);
44 44
 	}
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.