What are the advantages and disadvantages of allowing a game piece object to have knowledge of the game board object in PHP?

Allowing a game piece object to have knowledge of the game board object can make it easier to implement game logic and interactions between pieces. However, this can also lead to tight coupling between the objects, making the code harder to maintain and test.

<?php

class GameBoard {
    // Game board implementation
}

class GamePiece {
    private $gameBoard;

    public function __construct(GameBoard $gameBoard) {
        $this->gameBoard = $gameBoard;
    }

    // Game piece methods using $this->gameBoard
}

$gameBoard = new GameBoard();
$gamePiece = new GamePiece($gameBoard);

?>