Completed
Push — master ( 199c93...837735 )
by Jesse
01:53
created
src/Parser.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param \donatj\Printf\Emitter $emitter The given Emitter to emit Lexemes as parsed
21 21
 	 */
22
-	public function __construct( Emitter $emitter ) {
22
+	public function __construct(Emitter $emitter) {
23 23
 		$this->emitter = $emitter;
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * Parses a printf string and emit parsed lexemes to the configured Emitter
28 28
 	 */
29
-	public function parseStr( string $string ) : void {
29
+	public function parseStr(string $string) : void {
30 30
 		$lexer = new StringLexer($string);
31 31
 
32
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
33
-			if( $next->getString() === '%' ) {
34
-				if( $lexer->hasPrefix('%') ) {
32
+		while (($next = $lexer->next()) && !$next->isEof()) {
33
+			if ($next->getString() === '%') {
34
+				if ($lexer->hasPrefix('%')) {
35 35
 					$this->emitter->emit(
36 36
 						new Lexeme(Lexeme::T_LITERAL_STRING, '%', $lexer->pos())
37 37
 					);
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 		}
51 51
 	}
52 52
 
53
-	private function lexString( Emitter $emitter, StringLexer $lexer ) : void {
53
+	private function lexString(Emitter $emitter, StringLexer $lexer) : void {
54 54
 		$pos    = $lexer->pos();
55 55
 		$buffer = '';
56
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
57
-			if( $next->getString() === '%' ) {
56
+		while (($next = $lexer->next()) && !$next->isEof()) {
57
+			if ($next->getString() === '%') {
58 58
 				$lexer->rewind();
59 59
 				break;
60 60
 			}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		);
68 68
 	}
69 69
 
70
-	private function lexSprintf( Emitter $emitter, StringLexer $lexer ) : void {
70
+	private function lexSprintf(Emitter $emitter, StringLexer $lexer) : void {
71 71
 		$pos  = $lexer->pos();
72 72
 		$next = $lexer->next();
73 73
 
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
 		$leftJustified = null;
79 79
 		$precision     = null;
80 80
 
81
-		if( $next->getString() !== '0' && ctype_digit($next->getString()) ) {
81
+		if ($next->getString() !== '0' && ctype_digit($next->getString())) {
82 82
 			$lexer->rewind();
83 83
 			$int = $this->eatInt($lexer);
84
-			if( $lexer->hasPrefix('$') ) {
84
+			if ($lexer->hasPrefix('$')) {
85 85
 				$lexer->next();
86 86
 				$next = $lexer->next();
87 87
 				$arg  = $int;
88 88
 			}
89 89
 		}
90 90
 
91
-		switch( $next->getString() ) {
91
+		switch ($next->getString()) {
92 92
 			case '0':
93 93
 				$padChar = '0';
94 94
 				$next    = $lexer->next();
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 				$next    = $lexer->next();
104 104
 		}
105 105
 
106
-		if( $next->getString() === '-' ) {
106
+		if ($next->getString() === '-') {
107 107
 			$leftJustified = true;
108 108
 			$next          = $lexer->next();
109 109
 		}
110 110
 
111
-		if( $padChar !== null ) {
111
+		if ($padChar !== null) {
112 112
 			$lexer->rewind();
113 113
 			$peek = $lexer->peek();
114
-			if( ctype_digit($peek->getString()) ) {
114
+			if (ctype_digit($peek->getString())) {
115 115
 				$padWidth = $this->eatInt($lexer);
116 116
 			}
117 117
 
118 118
 			$next = $lexer->next();
119 119
 		}
120 120
 
121
-		if( $next->getString() === '.' ) {
122
-			if( ctype_digit($lexer->peek()->getString()) ) {
121
+		if ($next->getString() === '.') {
122
+			if (ctype_digit($lexer->peek()->getString())) {
123 123
 				$precision = $this->eatInt($lexer);
124 124
 			}
125 125
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 
129 129
 		$tType = Lexeme::T_INVALID;
130
-		if( in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true) ) {
130
+		if (in_array($next->getString(), ArgumentLexeme::VALID_T_TYPES, true)) {
131 131
 			$tType = $next->getString();
132 132
 		}
133 133
 
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 		);
149 149
 	}
150 150
 
151
-	private function eatInt( StringLexer $lexer ) : string {
151
+	private function eatInt(StringLexer $lexer) : string {
152 152
 		$int = '';
153
-		while( ($next = $lexer->next()) && !$next->isEof() ) {
154
-			if( !ctype_digit($next->getString()) ) {
153
+		while (($next = $lexer->next()) && !$next->isEof()) {
154
+			if (!ctype_digit($next->getString())) {
155 155
 				$lexer->rewind();
156 156
 				break;
157 157
 			}
Please login to merge, or discard this patch.