What are the best practices for handling the movement validation of chess pieces in a PHP chess game?

Issue: When developing a PHP chess game, it is important to ensure that the movement validation of chess pieces is implemented correctly to prevent illegal moves. This can be achieved by creating functions to check the validity of each piece's movement based on the rules of chess.

// Function to validate the movement of a pawn
function validatePawnMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the pawn's move is valid
}

// Function to validate the movement of a rook
function validateRookMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the rook's move is valid
}

// Function to validate the movement of a knight
function validateKnightMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the knight's move is valid
}

// Function to validate the movement of a bishop
function validateBishopMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the bishop's move is valid
}

// Function to validate the movement of a queen
function validateQueenMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the queen's move is valid
}

// Function to validate the movement of a king
function validateKingMove($startSquare, $endSquare, $color, $board) {
    // Implement logic to check if the king's move is valid
}