Completed
Push — master ( 5b464c...5e1a02 )
by Walter
16:59 queued 02:28
created
src/Notation.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
  */
18 18
 final class Notation
19 19
 {
20
-    const PIECE_PAWN = null;
21
-    const PIECE_BISHOP = 'B';
22
-    const PIECE_KING = 'K';
23
-    const PIECE_KNIGHT = 'N';
24
-    const PIECE_QUEEN = 'Q';
25
-    const PIECE_ROOK = 'R';
20
+    const PIECE_PAWN=null;
21
+    const PIECE_BISHOP='B';
22
+    const PIECE_KING='K';
23
+    const PIECE_KNIGHT='N';
24
+    const PIECE_QUEEN='Q';
25
+    const PIECE_ROOK='R';
26 26
 
27
-    const CASTLING_NONE = null;
28
-    const CASTLING_KING_SIDE = 'O-O';
29
-    const CASTLING_QUEEN_SIDE = 'O-O-O';
27
+    const CASTLING_NONE=null;
28
+    const CASTLING_KING_SIDE='O-O';
29
+    const CASTLING_QUEEN_SIDE='O-O-O';
30 30
 
31 31
     /**
32 32
      * The original value.
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function __construct(string $value)
115 115
     {
116
-        $this->value = $value;
117
-        $this->capture = false;
118
-        $this->check = false;
119
-        $this->checkmate = false;
116
+        $this->value=$value;
117
+        $this->capture=false;
118
+        $this->check=false;
119
+        $this->checkmate=false;
120 120
 
121 121
         $this->parse($value);
122 122
     }
@@ -131,110 +131,110 @@  discard block
 block discarded – undo
131 131
     {
132 132
         // Check for castling:
133 133
         if (preg_match('/^(O-O|O-O-O)(\+|\#?)$/', $value, $matches)) {
134
-            $this->castling = $matches[1];
135
-            $this->check = $matches[2] === '+';
136
-            $this->checkmate = $matches[2] === '#';
134
+            $this->castling=$matches[1];
135
+            $this->check=$matches[2] === '+';
136
+            $this->checkmate=$matches[2] === '#';
137 137
             return;
138 138
         }
139 139
 
140 140
         // Pawn movement:
141 141
         if (preg_match('/^([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
142
-            $this->targetColumn = $matches[1];
143
-            $this->targetRow = (int)$matches[2];
144
-            $this->check = $matches[3] === '+';
145
-            $this->checkmate = $matches[3] === '#';
146
-            $this->movedPiece = self::PIECE_PAWN;
142
+            $this->targetColumn=$matches[1];
143
+            $this->targetRow=(int) $matches[2];
144
+            $this->check=$matches[3] === '+';
145
+            $this->checkmate=$matches[3] === '#';
146
+            $this->movedPiece=self::PIECE_PAWN;
147 147
             return;
148 148
         }
149 149
 
150 150
         // Piece movement:
151 151
         if (preg_match('/^([KQBNR])([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
152
-            $this->movedPiece = $matches[1];
153
-            $this->targetColumn = $matches[2];
154
-            $this->targetRow = (int)$matches[3];
155
-            $this->check = $matches[4] === '+';
156
-            $this->checkmate = $matches[4] === '#';
152
+            $this->movedPiece=$matches[1];
153
+            $this->targetColumn=$matches[2];
154
+            $this->targetRow=(int) $matches[3];
155
+            $this->check=$matches[4] === '+';
156
+            $this->checkmate=$matches[4] === '#';
157 157
             return;
158 158
         }
159 159
 
160 160
         // Piece movement from a specific column:
161 161
         if (preg_match('/^([KQBNR])([a-h])([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
162
-            $this->movedPiece = $matches[1];
163
-            $this->movedPieceDisambiguationColumn = $matches[2];
164
-            $this->targetColumn = $matches[3];
165
-            $this->targetRow = (int)$matches[4];
166
-            $this->check = $matches[5] === '+';
167
-            $this->checkmate = $matches[5] === '#';
162
+            $this->movedPiece=$matches[1];
163
+            $this->movedPieceDisambiguationColumn=$matches[2];
164
+            $this->targetColumn=$matches[3];
165
+            $this->targetRow=(int) $matches[4];
166
+            $this->check=$matches[5] === '+';
167
+            $this->checkmate=$matches[5] === '#';
168 168
             return;
169 169
         }
170 170
 
171 171
         // Piece movement from a specific row:
172 172
         if (preg_match('/^([KQBNR])([0-9])([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
173
-            $this->movedPiece = $matches[1];
174
-            $this->movedPieceDisambiguationRow = (int)$matches[2];
175
-            $this->targetColumn = $matches[3];
176
-            $this->targetRow = (int)$matches[4];
177
-            $this->check = $matches[5] === '+';
178
-            $this->checkmate = $matches[5] === '#';
173
+            $this->movedPiece=$matches[1];
174
+            $this->movedPieceDisambiguationRow=(int) $matches[2];
175
+            $this->targetColumn=$matches[3];
176
+            $this->targetRow=(int) $matches[4];
177
+            $this->check=$matches[5] === '+';
178
+            $this->checkmate=$matches[5] === '#';
179 179
             return;
180 180
         }
181 181
 
182 182
         // Pawn capture:
183 183
         if (preg_match('/^([a-h])x([a-h])([1-8])(?:=([KQBNR]))?(\+|\#?)$/', $value, $matches)) {
184
-            $this->targetColumn = $matches[2];
185
-            $this->targetRow = (int)$matches[3];
186
-            $this->movedPiece = self::PIECE_PAWN;
187
-            $this->movedPieceDisambiguationColumn = $matches[1];
188
-            $this->capture = true;
189
-            $this->promotedPiece = $matches[4] ?: null;
190
-            $this->check = $matches[5] === '+';
191
-            $this->checkmate = $matches[5] === '#';
184
+            $this->targetColumn=$matches[2];
185
+            $this->targetRow=(int) $matches[3];
186
+            $this->movedPiece=self::PIECE_PAWN;
187
+            $this->movedPieceDisambiguationColumn=$matches[1];
188
+            $this->capture=true;
189
+            $this->promotedPiece=$matches[4] ?: null;
190
+            $this->check=$matches[5] === '+';
191
+            $this->checkmate=$matches[5] === '#';
192 192
             return;
193 193
         }
194 194
 
195 195
         // Piece capture:
196 196
         if (preg_match('/^([KQBNR])x([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
197
-            $this->movedPiece = $matches[1];
198
-            $this->targetColumn = $matches[2];
199
-            $this->targetRow = (int)$matches[3];
200
-            $this->check = $matches[4] === '+';
201
-            $this->checkmate = $matches[4] === '#';
202
-            $this->capture = true;
197
+            $this->movedPiece=$matches[1];
198
+            $this->targetColumn=$matches[2];
199
+            $this->targetRow=(int) $matches[3];
200
+            $this->check=$matches[4] === '+';
201
+            $this->checkmate=$matches[4] === '#';
202
+            $this->capture=true;
203 203
             return;
204 204
         }
205 205
 
206 206
         // Piece capture from a specific column:
207 207
         if (preg_match('/^([KQBNR])([a-h])x([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
208
-            $this->movedPiece = $matches[1];
209
-            $this->movedPieceDisambiguationColumn = $matches[2];
210
-            $this->targetColumn = $matches[3];
211
-            $this->targetRow = (int)$matches[4];
212
-            $this->check = $matches[5] === '+';
213
-            $this->checkmate = $matches[5] === '#';
214
-            $this->capture = true;
208
+            $this->movedPiece=$matches[1];
209
+            $this->movedPieceDisambiguationColumn=$matches[2];
210
+            $this->targetColumn=$matches[3];
211
+            $this->targetRow=(int) $matches[4];
212
+            $this->check=$matches[5] === '+';
213
+            $this->checkmate=$matches[5] === '#';
214
+            $this->capture=true;
215 215
             return;
216 216
         }
217 217
 
218 218
         // Piece capture from a specific column:
219 219
         if (preg_match('/^([KQBNR])([0-9])x([a-h])([1-8])(\+|\#?)$/', $value, $matches)) {
220
-            $this->movedPiece = $matches[1];
221
-            $this->movedPieceDisambiguationRow = (int)$matches[2];
222
-            $this->targetColumn = $matches[3];
223
-            $this->targetRow = (int)$matches[4];
224
-            $this->check = $matches[5] === '+';
225
-            $this->checkmate = $matches[5] === '#';
226
-            $this->capture = true;
220
+            $this->movedPiece=$matches[1];
221
+            $this->movedPieceDisambiguationRow=(int) $matches[2];
222
+            $this->targetColumn=$matches[3];
223
+            $this->targetRow=(int) $matches[4];
224
+            $this->check=$matches[5] === '+';
225
+            $this->checkmate=$matches[5] === '#';
226
+            $this->capture=true;
227 227
             return;
228 228
         }
229 229
 
230 230
         // Check for pawn promotion:
231 231
         if (preg_match('/^([a-h])([1-8])=([KQBNR])(\+|\#?)$/', $value, $matches)) {
232
-            $this->movedPiece = self::PIECE_PAWN;
233
-            $this->targetColumn = $matches[1];
234
-            $this->targetRow = (int)$matches[2];
235
-            $this->promotedPiece = $matches[3];
236
-            $this->check = $matches[4] === '+';
237
-            $this->checkmate = $matches[4] === '#';
232
+            $this->movedPiece=self::PIECE_PAWN;
233
+            $this->targetColumn=$matches[1];
234
+            $this->targetRow=(int) $matches[2];
235
+            $this->promotedPiece=$matches[3];
236
+            $this->check=$matches[4] === '+';
237
+            $this->checkmate=$matches[4] === '#';
238 238
             return;
239 239
         }
240 240
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
             throw new RuntimeException('No row has been set.');
333 333
         }
334 334
 
335
-        $notation = chr(97 + $index) . $this->getTargetRow();
335
+        $notation=chr(97 + $index).$this->getTargetRow();
336 336
 
337 337
         return new self($notation);
338 338
     }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      */
357 357
     public function withTargetRow(int $row): Notation
358 358
     {
359
-        $notation = $this->getTargetColumn() . $row;
359
+        $notation=$this->getTargetColumn().$row;
360 360
 
361 361
         return new self($notation);
362 362
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public function getTargetNotation(): string
370 370
     {
371
-        return $this->getTargetColumn() . $this->getTargetRow();
371
+        return $this->getTargetColumn().$this->getTargetRow();
372 372
     }
373 373
 
374 374
     /**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function setMovedPieceDisambiguationColumn(?string $movedPieceDisambiguationColumn): void
400 400
     {
401
-        $this->movedPieceDisambiguationColumn = $movedPieceDisambiguationColumn;
401
+        $this->movedPieceDisambiguationColumn=$movedPieceDisambiguationColumn;
402 402
     }
403 403
 
404 404
     /**
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public function setMovedPieceDisambiguationRow(?int $movedPieceDisambiguationRow): void
420 420
     {
421
-        $this->movedPieceDisambiguationRow = $movedPieceDisambiguationRow;
421
+        $this->movedPieceDisambiguationRow=$movedPieceDisambiguationRow;
422 422
     }
423 423
 
424 424
     /**
Please login to merge, or discard this patch.