<commit_before><?php
namespace Minesweeper\Square;

use Minesweeper\Grid;

/**
 * Base class for squares. Defines whether the square makes you lose the game
 * and holds it's direct surrounding squares for easier recursive
 * manipulations.
 *
 */
abstract class Square {

	/**
	 * @var  boolean  Whether the square is already revealed
	 */
	private $revealed = FALSE;

	/**
	 * @var  array  Simple array with surrounding squares
	 */
	private $surrounding_squares = array();

	/**
	 * @var bool	Whether the square has been flagged as bomb or not
	 */
	private $flagged = FALSE;

	/**
	 * Let the square reveal itself and its surroundings
	 *
	 * @return  boolean  Whether the game is over
	 */
	public function reveal()
	{
		// Set revealed
		$this->revealed = TRUE;
		$this->flagged = FALSE;

		// Return game over
		if ($game_over = $this->isGameOver())
		{
			return $game_over;
		}

		// Reveal surrounding squares if there are no game overs nearby
		if ($this->numberOfSurroundingGameOverSquares() === 0)
		{
			foreach ($this->getSurroundingSquares() as $square)
			{
				// Is auto revealable and not already revealed
				if ($square->isAutoRevealable() AND ! $square->isRevealed())
				{
					// Reveal
					$square->reveal();
				}
			}
		}
	}

	/**
	 * Toggle flag
	 */
	public function toggleFlag()
	{
		$this->flagged = ! $this->flagged;
	}

	/**
	 * Wheter the squalre has been flagged as bomb or not
	 *
	 * @return boolean
	 */
	public function isFlagged()
	{
		return $this->flagged;
	}

	/**<commit_msg>Renamed bomb to mine on Square<commit_after><?php
namespace Minesweeper\Square;

use Minesweeper\Grid;

/**
 * Base class for squares. Defines whether the square makes you lose the game
 * and holds it's direct surrounding squares for easier recursive
 * manipulations.
 *
 */
abstract class Square {

	/**
	 * @var  boolean  Whether the square is already revealed
	 */
	private $revealed = FALSE;

	/**
	 * @var  array  Simple array with surrounding squares
	 */
	private $surrounding_squares = array();

	/**
	 * @var bool	Whether the square has been flagged as mine or not
	 */
	private $flagged = FALSE;

	/**
	 * Let the square reveal itself and its surroundings
	 *
	 * @return  boolean  Whether the game is over
	 */
	public function reveal()
	{
		// Set revealed
		$this->revealed = TRUE;
		$this->flagged = FALSE;

		// Return game over
		if ($game_over = $this->isGameOver())
		{
			return $game_over;
		}

		// Reveal surrounding squares if there are no game overs nearby
		if ($this->numberOfSurroundingGameOverSquares() === 0)
		{
			foreach ($this->getSurroundingSquares() as $square)
			{
				// Is auto revealable and not already revealed
				if ($square->isAutoRevealable() AND ! $square->isRevealed())
				{
					// Reveal
					$square->reveal();
				}
			}
		}
	}

	/**
	 * Toggle flag
	 */
	public function toggleFlag()
	{
		$this->flagged = ! $this->flagged;
	}

	/**
	 * Wheter the squalre has been flagged as mine or not
	 *
	 * @return boolean
	 */
	public function isFlagged()
	{
		return $this->flagged;
	}

	/**
{'fraction_non_alphanumeric': 0.11899313501144165, 'fraction_numerical': 0.0006538084341288003, 'mean_word_length': 2.9130434782608696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2994075', 'n_tokens_mistral': 1114, 'n_tokens_neox': 950, 'n_words': 311}