wolfenste / tictactoe

0 stars 0 forks source link

Player violates SOLID #6

Closed flavius closed 6 years ago

flavius commented 6 years ago

The problems with this class start with the constructor

public function __construct (char $mark, $lines) : void {
  1. The player class should accept a Mark instance, already validated. You want to input value objects into your other classes, which are by definition already validated syntactically. char $mark is wrong, why a "char" when you already have a class for this? Better: Mark $mark.

  2. In real-life, the player's sole job is to decide where to put next his symbol, given a state of the map. It should not hold itself the symbols (that's what Map is for) or any other state.