55namespace ChessZebra \ForsythEdwardsNotation ;
66
77use ChessZebra \ForsythEdwardsNotation \Exception \InvalidFenException ;
8+
89use function explode ;
910
1011/**
@@ -17,18 +18,14 @@ final class FenNotation
1718
1819 /**
1920 * The places of the pieces.
20- *
21- * @var string
2221 */
23- private $ piecePlacement ;
22+ private string $ piecePlacement ;
2423
2524 /**
2625 * An indication whether its black or white's turn.
2726 * The value 'b' means black, 'w' means white.
28- *
29- * @var string
3027 */
31- private $ turn ;
28+ private string $ turn ;
3229
3330 /**
3431 * A value that indicates whether or not castling is available.
@@ -37,35 +34,27 @@ final class FenNotation
3734 * - "Q" (White can castle queenside),
3835 * - "k" (Black can castle kingside), and/or
3936 * - "q" (Black can castle queenside).
40- *
41- * @var CastlingAvailability
4237 */
43- private $ castlingAvailability ;
38+ private CastlingAvailability $ castlingAvailability ;
4439
4540 /**
4641 * En passant target square in Standard Algebraic Notation (SAN).
4742 * If there's no en passant target square, this value is null. If a pawn has just made a two-square move, this is
4843 * the position "behind" the pawn. This is recorded regardless of whether there is a pawn in position to make an
4944 * en passant capture.
50- *
51- * @var string|null
5245 */
53- private $ enPassantTargetSquare ;
46+ private ? string $ enPassantTargetSquare ;
5447
5548 /**
5649 * Halfmove clock: This is the number of halfmoves since the last capture or pawn advance. This is used to
5750 * determine if a draw can be claimed under the fifty-move rule.
58- *
59- * @var int
6051 */
61- private $ halfMoveClock ;
52+ private int $ halfMoveClock ;
6253
6354 /**
6455 * Fullmove number: The number of the full move. It starts at 1, and is incremented after Black's move.
65- *
66- * @var int
6756 */
68- private $ fullMoveNumber ;
57+ private int $ fullMoveNumber ;
6958
7059 public function __construct (string $ fen )
7160 {
@@ -91,29 +80,39 @@ private function validate(string $fen): void
9180
9281 case ValidationResult::EN_PASSANT_INVALID_MOVE :
9382 throw InvalidFenException::enPassantIllegal ($ fen );
83+
9484 case ValidationResult::EN_PASSANT_INVALID_SQUARE :
9585 throw InvalidFenException::enPassantInvalidSquare ($ fen );
86+
9687 case ValidationResult::FIELD_COUNT_TOO_LARGE :
9788 case ValidationResult::FIELD_COUNT_TOO_SMALL :
9889 throw InvalidFenException::incorrectFieldCount ($ fen );
90+
9991 case ValidationResult::INVALID_CASTLING_PIECE :
10092 throw InvalidFenException::invalidCastlingPiece ($ fen );
93+
10194 case ValidationResult::INVALID_TURN :
10295 throw InvalidFenException::invalidTurn ($ fen );
96+
10397 case ValidationResult::HALFMOVE_COUNTER_NAN :
10498 throw InvalidFenException::wrongHalfMoveCounter ($ fen );
99+
105100 case ValidationResult::MOVE_NUMBER_NAN :
106101 case ValidationResult::MOVE_NUMBER_POSITIVE :
107102 throw InvalidFenException::wrongMoveNumber ($ fen );
103+
108104 case ValidationResult::PIECE_CONSECUTIVE_NUMBERS :
109105 case ValidationResult::PIECE_INVALID :
110106 throw InvalidFenException::invalidPiecePlacement ($ fen );
107+
111108 case ValidationResult::PIECE_ROW_TOO_LARGE :
112109 case ValidationResult::PIECE_ROW_TOO_SMALL :
113110 throw InvalidFenException::incorrectPiecePlacementRowLength ($ fen );
111+
114112 case ValidationResult::PIECE_NOT_ENOUGH_ROWS :
115113 case ValidationResult::PIECE_TOO_MANY_ROWS :
116114 throw InvalidFenException::incorrectPiecePlacementRowsLength ($ fen );
115+
117116 default :
118117 throw InvalidFenException::unepectedError ($ fen ); // @codeCoverageIgnore
119118 }
0 commit comments