Passed
Pull Request — master (#8)
by Jesse
04:16 queued 01:22
created
src/LexemeEmitter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	/**
11 11
 	 * @internal This is for use by the Parser
12 12
 	 */
13
-	public function emit( Lexeme $lexItem ) : void {
13
+	public function emit(Lexeme $lexItem) : void {
14 14
 		$this->lexemes[] = $lexItem;
15 15
 	}
16 16
 
Please login to merge, or discard this patch.
src/StringLexer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * StringScanner constructor.
15 15
 	 */
16
-	public function __construct( string $string ) {
16
+	public function __construct(string $string) {
17 17
 		$this->string = $string;
18 18
 	}
19 19
 
20
-	public function peek( int $size = 1 ) : CharData {
20
+	public function peek(int $size = 1) : CharData {
21 21
 		$str = substr($this->string, $this->pos, $size);
22 22
 
23 23
 		return new CharData($str, strlen($str) < $size);
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 
38 38
 	public function rewind() : void {
39 39
 		$this->pos--;
40
-		if( $this->pos < 0 ) {
40
+		if ($this->pos < 0) {
41 41
 			//@todo custom exception
42 42
 			throw new \RuntimeException('cannot rewind');
43 43
 		}
44 44
 	}
45 45
 
46
-	public function hasPrefix( string $prefix ) : bool {
46
+	public function hasPrefix(string $prefix) : bool {
47 47
 		$peek = $this->peek(strlen($prefix));
48 48
 
49 49
 		return $peek->getString() === $prefix;
50 50
 	}
51 51
 
52
-	public function substr( int $start, int $length ) : string {
52
+	public function substr(int $start, int $length) : string {
53 53
 		return substr($this->string, $start, $length);
54 54
 	}
55 55
 
Please login to merge, or discard this patch.
src/Parser.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param \donatj\Printf\Emitter $emitter The given Emitter to emit Lexemes as parsed
19 19
 	 */
20
-	public function __construct( Emitter $emitter ) {
20
+	public function __construct(Emitter $emitter) {
21 21
 		$this->emitter = $emitter;
22 22
 	}
23 23
 
24 24
 	/**
25 25
 	 * Parses a printf string and emit parsed lexemes to the configured Emitter
26 26
 	 */
27
-	public function parseStr( string $string ) : void {
27
+	public function parseStr(string $string) : void {
28 28
 		$lexer = new StringLexer($string);
29 29
 
30
-		for(;;) {
30
+		for (;;) {
31 31
 			$next = $lexer->next();
32
-			if( $next->isEof() ) {
32
+			if ($next->isEof()) {
33 33
 				break;
34 34
 			}
35 35
 
36
-			if( $next->getString() === '%' ) {
37
-				if( $lexer->hasPrefix('%') ) {
36
+			if ($next->getString() === '%') {
37
+				if ($lexer->hasPrefix('%')) {
38 38
 					$this->emitter->emit(
39 39
 						new Lexeme(Lexeme::T_LITERAL_STRING, '%', $lexer->pos())
40 40
 					);
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 		}
54 54
 	}
55 55
 
56
-	private function lexString( Emitter $emitter, StringLexer $lexer ) : void {
56
+	private function lexString(Emitter $emitter, StringLexer $lexer) : void {
57 57
 		$pos    = $lexer->pos();
58 58
 		$buffer = '';
59
-		for(;;) {
59
+		for (;;) {
60 60
 			$next = $lexer->next();
61
-			if( $next->isEof() ) {
61
+			if ($next->isEof()) {
62 62
 				break;
63 63
 			}
64 64
 
65
-			if( $next->getString() === '%' ) {
65
+			if ($next->getString() === '%') {
66 66
 				$lexer->rewind();
67 67
 				break;
68 68
 			}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		);
76 76
 	}
77 77
 
78
-	private function lexSprintf( Emitter $emitter, StringLexer $lexer ) : void {
78
+	private function lexSprintf(Emitter $emitter, StringLexer $lexer) : void {
79 79
 		$pos  = $lexer->pos();
80 80
 		$next = $lexer->next();
81 81
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 		$leftJustified = false;
87 87
 		$precision     = null;
88 88
 
89
-		if( $next->getString() !== '0' && ctype_digit($next->getString()) ) {
89
+		if ($next->getString() !== '0' && ctype_digit($next->getString())) {
90 90
 			$lexer->rewind();
91 91
 			$int = $this->eatInt($lexer);
92
-			if( $lexer->hasPrefix('$') ) {
92
+			if ($lexer->hasPrefix('$')) {
93 93
 				$lexer->next();
94 94
 				$next = $lexer->next();
95 95
 				$arg  = $int;
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 		}
98 98
 
99 99
 		// flag parsing
100
-		for(;;) {
101
-			switch( $next->getString() ) {
100
+		for (;;) {
101
+			switch ($next->getString()) {
102 102
 				case '0':
103 103
 					$padChar = '0';
104 104
 					$next    = $lexer->next();
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 					continue 2;
118 118
 			}
119 119
 
120
-			if( $next->getString() === '-' ) {
120
+			if ($next->getString() === '-') {
121 121
 				$leftJustified = true;
122 122
 				$next          = $lexer->next();
123 123
 
124 124
 				continue;
125 125
 			}
126 126
 
127
-			if( $next->getString() === '+' ) {
127
+			if ($next->getString() === '+') {
128 128
 				$showPositive = true;
129 129
 				$next         = $lexer->next();
130 130
 
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
 			break;
135 135
 		}
136 136
 
137
-		if( $padChar !== null ) {
137
+		if ($padChar !== null) {
138 138
 			$lexer->rewind();
139 139
 			$peek = $lexer->peek();
140
-			if( ctype_digit($peek->getString()) ) {
140
+			if (ctype_digit($peek->getString())) {
141 141
 				$padWidth = $this->eatInt($lexer);
142 142
 			}
143 143
 
144 144
 			$next = $lexer->next();
145 145
 		}
146 146
 
147
-		if( $next->getString() === '.' ) {
148
-			if( ctype_digit($lexer->peek()->getString()) ) {
147
+		if ($next->getString() === '.') {
148
+			if (ctype_digit($lexer->peek()->getString())) {
149 149
 				$precision = $this->eatInt($lexer);
150 150
 			}
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 
155 155
 		$tType = Lexeme::T_INVALID;
156
-		if( in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true) ) {
156
+		if (in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true)) {
157 157
 			$tType = $next->getString();
158 158
 		}
159 159
 
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 		);
175 175
 	}
176 176
 
177
-	private function eatInt( StringLexer $lexer ) : ?int {
177
+	private function eatInt(StringLexer $lexer) : ?int {
178 178
 		$int = '';
179
-		for(;;) {
179
+		for (;;) {
180 180
 			$next = $lexer->next();
181
-			if( $next->isEof() ) {
181
+			if ($next->isEof()) {
182 182
 				break;
183 183
 			}
184 184
 
185
-			if( !ctype_digit($next->getString()) ) {
185
+			if (!ctype_digit($next->getString())) {
186 186
 				$lexer->rewind();
187 187
 				break;
188 188
 			}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 			$int .= $next->getString();
191 191
 		}
192 192
 
193
-		if( $int ) {
194
-			return (int)$int;
193
+		if ($int) {
194
+			return (int) $int;
195 195
 		}
196 196
 
197 197
 		return null;
Please login to merge, or discard this patch.
src/Emitter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,6 +7,6 @@
 block discarded – undo
7 7
 	/**
8 8
 	 * @internal This is for use by the Parser
9 9
 	 */
10
-	public function emit( Lexeme $lexItem ) : void;
10
+	public function emit(Lexeme $lexItem) : void;
11 11
 
12 12
 }
Please login to merge, or discard this patch.