diff --git a/.idea/coffeetable.iml b/.idea/coffeetable.iml
index aaecbfc..fe3b477 100644
--- a/.idea/coffeetable.iml
+++ b/.idea/coffeetable.iml
@@ -3,10 +3,14 @@
+
+
+
+
@@ -24,6 +28,9 @@
+
+
+
@@ -34,7 +41,9 @@
+
+
@@ -52,13 +61,18 @@
+
+
+
+
+
@@ -76,9 +90,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..b07f6ac
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..3b31283
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ae8a4d0..4324d30 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,23 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -31,21 +46,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -54,7 +59,7 @@
-
+
@@ -64,7 +69,7 @@
-
+
@@ -74,8 +79,8 @@
-
-
+
+
@@ -84,8 +89,28 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -94,13 +119,33 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -108,11 +153,15 @@
+
+
+
+
@@ -188,6 +237,11 @@
+
+
+
+
+
@@ -274,9 +328,6 @@
Spelling
-
- UndefinedPHP
-
XML
@@ -286,7 +337,27 @@
- PhpUndefinedFieldInspection
+ PhpCSValidationInspection
+
+
+
+
+
+
+
+
+
+
+
+ PHP
+
+
+ UnusedPHP
+
+
+
+
+ MessDetectorValidationInspection
@@ -395,7 +466,7 @@
-
+
@@ -658,7 +729,13 @@
1458293744076
-
+
+ 1458293898715
+
+
+ 1458293898715
+
+
@@ -701,12 +778,13 @@
+
-
+
-
+
@@ -714,10 +792,31 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -735,7 +834,6 @@
-
@@ -760,7 +858,8 @@
-
+
+
@@ -928,13 +1027,6 @@
-
-
-
-
-
-
-
@@ -1020,66 +1112,106 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/composer.json b/composer.json
index a413d2d..2607e00 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,7 @@
{
"require-dev": {
- "phpunit/phpunit": "5.2.*"
+ "phpunit/phpunit": "5.2.*",
+ "phpmd/phpmd": "@stable"
},
"autoload-dev": {
"psr-0": {
diff --git a/composer.lock b/composer.lock
index 0169cb9..9ff2d9b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "2886793b37f8ff226b298154be898209",
- "content-hash": "5c48139016fec53f7c43de7c6ff8508d",
+ "hash": "835e1d546c82d631358062e62966525c",
+ "content-hash": "8c9ffcab7de4c22d081223c7d31ad609",
"packages": [],
"packages-dev": [
{
@@ -104,6 +104,46 @@
],
"time": "2015-11-07 22:20:37"
},
+ {
+ "name": "pdepend/pdepend",
+ "version": "2.2.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/pdepend/pdepend.git",
+ "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b086687f3a01dc6bb92d633aef071d2c5dd0db06",
+ "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.7",
+ "symfony/config": "^2.3.0|^3",
+ "symfony/dependency-injection": "^2.3.0|^3",
+ "symfony/filesystem": "^2.3.0|^3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.4.0,<4.8",
+ "squizlabs/php_codesniffer": "^2.0.0"
+ },
+ "bin": [
+ "src/bin/pdepend"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PDepend\\": "src/main/php/PDepend"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "description": "Official version of pdepend to be handled with Composer",
+ "time": "2016-03-10 15:15:04"
+ },
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",
@@ -153,6 +193,71 @@
],
"time": "2015-02-03 12:10:50"
},
+ {
+ "name": "phpmd/phpmd",
+ "version": "2.4.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpmd/phpmd.git",
+ "reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpmd/phpmd/zipball/fccbdb6b222f6d7a6d35af1c396ba5435cec76a9",
+ "reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9",
+ "shasum": ""
+ },
+ "require": {
+ "pdepend/pdepend": "~2.0",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0",
+ "squizlabs/php_codesniffer": "^2.0"
+ },
+ "bin": [
+ "src/bin/phpmd"
+ ],
+ "type": "project",
+ "autoload": {
+ "psr-0": {
+ "PHPMD\\": "src/main/php"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Manuel Pichler",
+ "email": "github@manuel-pichler.de",
+ "homepage": "https://github.com/manuelpichler",
+ "role": "Project Founder"
+ },
+ {
+ "name": "Other contributors",
+ "homepage": "https://github.com/phpmd/phpmd/graphs/contributors",
+ "role": "Contributors"
+ },
+ {
+ "name": "Marc Würth",
+ "email": "ravage@bluewin.ch",
+ "homepage": "https://github.com/ravage84",
+ "role": "Project Maintainer"
+ }
+ ],
+ "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.",
+ "homepage": "http://phpmd.org/",
+ "keywords": [
+ "mess detection",
+ "mess detector",
+ "pdepend",
+ "phpmd",
+ "pmd"
+ ],
+ "time": "2016-03-10 17:17:44"
+ },
{
"name": "phpspec/prophecy",
"version": "v1.6.0",
@@ -1052,6 +1157,167 @@
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-02-04 12:56:52"
},
+ {
+ "name": "symfony/config",
+ "version": "v3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/config.git",
+ "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/config/zipball/79a97025f7bf4bbf8352b5df1905aa136a531066",
+ "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.9",
+ "symfony/filesystem": "~2.8|~3.0"
+ },
+ "suggest": {
+ "symfony/yaml": "To use the yaml reference dumper"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Config\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Config Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-02-23 15:16:06"
+ },
+ {
+ "name": "symfony/dependency-injection",
+ "version": "v3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/dependency-injection.git",
+ "reference": "821800ae6753b88dab55a7280811d8734b8112bf"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/821800ae6753b88dab55a7280811d8734b8112bf",
+ "reference": "821800ae6753b88dab55a7280811d8734b8112bf",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.9"
+ },
+ "require-dev": {
+ "symfony/config": "~2.8|~3.0",
+ "symfony/expression-language": "~2.8|~3.0",
+ "symfony/yaml": "~2.8|~3.0"
+ },
+ "suggest": {
+ "symfony/config": "",
+ "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
+ "symfony/yaml": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\DependencyInjection\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony DependencyInjection Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-02-28 16:50:08"
+ },
+ {
+ "name": "symfony/filesystem",
+ "version": "v3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/filesystem.git",
+ "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
+ "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Filesystem\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Filesystem Component",
+ "homepage": "https://symfony.com",
+ "time": "2016-02-23 15:16:06"
+ },
{
"name": "symfony/yaml",
"version": "v3.0.3",
@@ -1104,7 +1370,9 @@
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {
+ "phpmd/phpmd": 0
+ },
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
diff --git a/src/Coffee/Map.php b/src/Coffee/Map.php
index 5988355..525b086 100644
--- a/src/Coffee/Map.php
+++ b/src/Coffee/Map.php
@@ -2,11 +2,11 @@
namespace Coffee;
- /**
- * Class Map
- *
- * @package Coffee
- */
+ /**
+ * Class Map
+ *
+ * @package Coffee
+ */
/**
* Class Map
*
@@ -14,137 +14,137 @@ namespace Coffee;
*/
class Map {
- /**
- * @var Tile[]
- */
- private $tiles = [];
-
- /**
- * @var int
- */
- private $height = 0;
- /**
- * @var int
- */
- private $width = 0;
-
- /**
- * Map constructor.
- *
- * @param $description [][]
- * @throws \Exception
- */
- public function __construct($description) {
- // The description must be 2D array containing at least one element
- if (is_null($description) || !is_array($description) || !is_array($description[0]) || count($description[0]) < 1) {
- throw new \Exception('The Coffee Table map could not be loaded.');
- }
-
- $height = 0;
- $width = 0;
-
- // This data processing could be written more read-ably in multiple cycles / private methods,
- // but at a cost of reduced performance (minor).
- foreach ($description as $rowIndex => $row) {
- foreach ($row as $columnIndex => $tileRepresentation) {
- // W need to convert indices to positions
- $this->tiles[] = new Tile($rowIndex + 1, $columnIndex + 1, $tileRepresentation);
-
- // Find maximum
- $width = $columnIndex > $width ? $columnIndex : $width;
- }
-
- // Find maximum
- $height = $rowIndex > $height ? $rowIndex : $height;
- }
-
- // Convert indices to dimensions
- $this->height = $height + 1;
- $this->width = $width + 1;
- }
-
- /**
- * @return Tile[]
- */
- public function getTiles() {
- return $this->tiles;
- }
-
- /**
- * @return Tile[]
- */
- public function getUnvisitedTiles() {
- $array = [];
- foreach ($this->getTiles() as $tile) {
- if (!$tile->isVisited()) {
- $array[] = $tile;
- }
- }
- return $array;
- }
-
- public function getUnvisitedTile() {
- foreach ($this->getTiles() as $tile) {
- if (!$tile->isVisited()) {
- return $tile;
- }
- }
-
- return false;
- }
-
- /**
- * @param Position $position
- * @return Tile|null
- */
- public function getTileByPosition(Position $position) {
- foreach ($this->getTiles() as $tile) {
- if ($tile->isTheSamePosition($position)) {
- return $tile;
- }
- }
-
- return null;
- }
-
- /**
- * @return array
- */
- public function describedByArray() {
- $array = [];
-
- foreach ($this->getTiles() as $tile) {
- $array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->isRepresentingSpot();
- }
-
- return $array;
- }
-
- /**
- * @param Tile $tile
- * @return Tile[]
- */
- public function getNeighboursOfTile(Tile $tile) {
- $neighbouringTiles = [];
- foreach ($tile->getNeighbouringPositions() as $neighbouringPosition) {
- $neighbouringTiles[] = $this->getTileByPosition($neighbouringPosition);
- }
- return array_values(array_filter($neighbouringTiles));
- }
-
- /**
- * @return int
- */
- public function getHeight() {
- return $this->height;
- }
-
- /**
- * @return int
- */
- public function getWidth() {
- return $this->width;
- }
+ /**
+ * @var Tile[]
+ */
+ private $tiles = [];
+
+ /**
+ * @var int
+ */
+ private $height = 0;
+ /**
+ * @var int
+ */
+ private $width = 0;
+
+ /**
+ * Map constructor.
+ *
+ * @param $description [][]
+ * @throws \Exception
+ */
+ public function __construct($description) {
+ // The description must be 2D array containing at least one element
+ if (is_null($description) || !is_array($description) || !is_array($description[0]) || count($description[0]) < 1) {
+ throw new \Exception('The Coffee Table map could not be loaded.');
+ }
+
+ $height = 0;
+ $width = 0;
+
+ // This data processing could be written more read-ably in multiple cycles / private methods,
+ // but at a cost of reduced performance (minor).
+ foreach ($description as $rowIndex => $row) {
+ foreach ($row as $columnIndex => $tileRepresentation) {
+ // W need to convert indices to positions
+ $this->tiles[] = new Tile($rowIndex + 1, $columnIndex + 1, $tileRepresentation);
+
+ // Find maximum
+ $width = $columnIndex > $width ? $columnIndex : $width;
+ }
+
+ // Find maximum
+ $height = $rowIndex > $height ? $rowIndex : $height;
+ }
+
+ // Convert indices to dimensions
+ $this->height = $height + 1;
+ $this->width = $width + 1;
+ }
+
+ /**
+ * @return Tile[]
+ */
+ public function getTiles() {
+ return $this->tiles;
+ }
+
+ /**
+ * @return Tile[]
+ */
+ public function getUnvisitedTiles() {
+ $array = [];
+ foreach ($this->getTiles() as $tile) {
+ if (!$tile->isVisited()) {
+ $array[] = $tile;
+ }
+ }
+ return $array;
+ }
+
+ public function getUnvisitedTile() {
+ foreach ($this->getTiles() as $tile) {
+ if (!$tile->isVisited()) {
+ return $tile;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param Position $position
+ * @return Tile|null
+ */
+ public function getTileByPosition(Position $position) {
+ foreach ($this->getTiles() as $tile) {
+ if ($tile->isTheSamePosition($position)) {
+ return $tile;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return array
+ */
+ public function describedByArray() {
+ $array = [];
+
+ foreach ($this->getTiles() as $tile) {
+ $array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->isRepresentingSpot();
+ }
+
+ return $array;
+ }
+
+ /**
+ * @param Tile $tile
+ * @return Tile[]
+ */
+ public function getNeighboursOfTile(Tile $tile) {
+ $neighbouringTiles = [];
+ foreach ($tile->getNeighbouringPositions() as $neighbouringPosition) {
+ $neighbouringTiles[] = $this->getTileByPosition($neighbouringPosition);
+ }
+ return array_values(array_filter($neighbouringTiles));
+ }
+
+ /**
+ * @return int
+ */
+ public function getHeight() {
+ return $this->height;
+ }
+
+ /**
+ * @return int
+ */
+ public function getWidth() {
+ return $this->width;
+ }
//
// /**
// * @param Position $position
diff --git a/src/Coffee/Position.php b/src/Coffee/Position.php
index 8a10aa8..d4ccb3f 100644
--- a/src/Coffee/Position.php
+++ b/src/Coffee/Position.php
@@ -2,11 +2,11 @@
namespace Coffee;
-/**
- * Class Position
- *
- * @package Coffee
- */
+ /**
+ * Class Position
+ *
+ * @package Coffee
+ */
/**
* Class Position
*
@@ -14,184 +14,184 @@ namespace Coffee;
*/
class Position {
- /**
- * The lowest possible position for rows and columns
- */
- const LOWER_BOUND = 1;
-
- /**
- * @var int
- */
- private $column = 0;
- /**
- * @var int
- */
- private $row = 0;
-
- /**
- * @param $row
- * @param $column
- * @throws \Exception
- */
- function __construct($row, $column) {
- if (!$this->fitsIntoLowerBound($row, $column)) {
- throw new \Exception('The row argument must be higher than ' . self::LOWER_BOUND . '.');
- }
-
- $this->column = $column;
- $this->row = $row;
- }
-
- /**
- * @return int
- */
- public function getColumn() {
- return $this->column;
- }
-
- /**
- * @return int
- */
- public function getColumnIndex() {
- return $this->column - 1;
- }
-
- /**
- * @return int
- */
- public function getRow() {
- return $this->row;
- }
-
- /**
- * @return int
- */
- public function getRowIndex() {
- return $this->row - 1;
- }
-
- /**
- * @param Position $position
- * @return bool
- */
- public function isTheSameColumn(Position $position) {
- return $this->getColumn() == $position->getColumn();
- }
-
- /**
- * @param Position $position
- * @return bool
- */
- public function isTheSameRow(Position $position) {
- return $this->getRow() == $position->getRow();
- }
-
- /**
- * @param Position $position
- * @return bool
- */
- public function isTheSamePosition(Position $position) {
- return $this->isTheSameColumn($position) && $this->isTheSameRow($position);
- }
-
- /**
- * @return Position
- */
- public function getNorthEastPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() + 1);
- }
-
- /**
- * @return Position
- */
- public function getEastPosition() {
- return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() + 1);
- }
-
- /**
- * @return Position
- */
- public function getSouthEastPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() + 1);
- }
-
- /**
- * @return Position
- */
- public function getSouthPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn());
- }
-
- /**
- * @return Position
- */
- public function getSouthWestPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() - 1);
- }
-
- /**
- * @return Position
- */
- public function getWestPosition() {
- return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() - 1);
- }
-
- /**
- * @return Position
- */
- public function getNorthWestPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() - 1);
- }
-
- /**
- * @return Position
- */
- public function getNorthPosition() {
- return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn());
- }
-
- /**
- * @return array Positions of neighbours from NE to N; CW direction
- */
- public function getNeighbouringPositions() {
-
- // null values from out-of-lower-bound neighbours are filtered out and indices are fixed
- return array_values(array_filter([
- $this->getNorthEastPosition(),
- $this->getEastPosition(),
- $this->getSouthEastPosition(),
- $this->getSouthPosition(),
- $this->getSouthWestPosition(),
- $this->getWestPosition(),
- $this->getNorthWestPosition(),
- $this->getNorthPosition(),
- ]));
- }
-
- /**
- * @param $row
- * @param $column
- * @return bool
- */
- protected function fitsIntoLowerBound($row, $column) {
- if ($row < self::LOWER_BOUND || $column < self::LOWER_BOUND) {
- return false;
- }
-
- return true;
- }
-
- /**
- * @param $row
- * @param $column
- * @return Position|null
- */
- protected function getSafeNeighbourPosition($row, $column) {
- if ($this->fitsIntoLowerBound($row, $column)) {
- return new Position($row, $column);
- }
-
- return null;
- }
+ /**
+ * The lowest possible position for rows and columns
+ */
+ const LOWER_BOUND = 1;
+
+ /**
+ * @var int
+ */
+ private $column = 0;
+ /**
+ * @var int
+ */
+ private $row = 0;
+
+ /**
+ * @param $row
+ * @param $column
+ * @throws \Exception
+ */
+ function __construct($row, $column) {
+ if (!$this->fitsIntoLowerBound($row, $column)) {
+ throw new \Exception('The row argument must be higher than ' . self::LOWER_BOUND . '.');
+ }
+
+ $this->column = $column;
+ $this->row = $row;
+ }
+
+ /**
+ * @return int
+ */
+ public function getColumn() {
+ return $this->column;
+ }
+
+ /**
+ * @return int
+ */
+ public function getColumnIndex() {
+ return $this->column - 1;
+ }
+
+ /**
+ * @return int
+ */
+ public function getRow() {
+ return $this->row;
+ }
+
+ /**
+ * @return int
+ */
+ public function getRowIndex() {
+ return $this->row - 1;
+ }
+
+ /**
+ * @param Position $position
+ * @return bool
+ */
+ public function isTheSameColumn(Position $position) {
+ return $this->getColumn() == $position->getColumn();
+ }
+
+ /**
+ * @param Position $position
+ * @return bool
+ */
+ public function isTheSameRow(Position $position) {
+ return $this->getRow() == $position->getRow();
+ }
+
+ /**
+ * @param Position $position
+ * @return bool
+ */
+ public function isTheSamePosition(Position $position) {
+ return $this->isTheSameColumn($position) && $this->isTheSameRow($position);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getNorthEastPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() + 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getEastPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() + 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getSouthEastPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() + 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getSouthPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn());
+ }
+
+ /**
+ * @return Position
+ */
+ public function getSouthWestPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() + 1, $this->getColumn() - 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getWestPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow(), $this->getColumn() - 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getNorthWestPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn() - 1);
+ }
+
+ /**
+ * @return Position
+ */
+ public function getNorthPosition() {
+ return $this->getSafeNeighbourPosition($this->getRow() - 1, $this->getColumn());
+ }
+
+ /**
+ * @return array Positions of neighbours from NE to N; CW direction
+ */
+ public function getNeighbouringPositions() {
+
+ // null values from out-of-lower-bound neighbours are filtered out and indices are fixed
+ return array_values(array_filter([
+ $this->getNorthEastPosition(),
+ $this->getEastPosition(),
+ $this->getSouthEastPosition(),
+ $this->getSouthPosition(),
+ $this->getSouthWestPosition(),
+ $this->getWestPosition(),
+ $this->getNorthWestPosition(),
+ $this->getNorthPosition(),
+ ]));
+ }
+
+ /**
+ * @param $row
+ * @param $column
+ * @return bool
+ */
+ protected function fitsIntoLowerBound($row, $column) {
+ if ($row < self::LOWER_BOUND || $column < self::LOWER_BOUND) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @param $row
+ * @param $column
+ * @return Position|null
+ */
+ protected function getSafeNeighbourPosition($row, $column) {
+ if ($this->fitsIntoLowerBound($row, $column)) {
+ return new Position($row, $column);
+ }
+
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/Coffee/Spot.php b/src/Coffee/Spot.php
index 3de51e5..12e087b 100644
--- a/src/Coffee/Spot.php
+++ b/src/Coffee/Spot.php
@@ -8,11 +8,11 @@
namespace Coffee;
-/**
- * Class Spot
- *
- * @package Coffee
- */
+ /**
+ * Class Spot
+ *
+ * @package Coffee
+ */
/**
* Class Spot
*
@@ -20,38 +20,38 @@ namespace Coffee;
*/
class Spot {
- /**
- * @var Position[]
- */
- private $positions = [];
-
- /**
- * Spot constructor.
- *
- * @param Position $position
- */
- public function __construct(Position $position) {
- $this->positions[] = $position;
- }
-
- /**
- * @param Position $position
- * @return bool
- */
- public function addPosition(Position $position) {
- if (is_null($position)) {
- return false;
- }
-
- $this->positions[] = $position;
- return true;
- }
-
- /**
- * @return Position[]
- */
- public function getPositions() {
- return $this->positions;
- }
+ /**
+ * @var Position[]
+ */
+ private $positions = [];
+
+ /**
+ * Spot constructor.
+ *
+ * @param Position $position
+ */
+ public function __construct(Position $position) {
+ $this->positions[] = $position;
+ }
+
+ /**
+ * @param Position $position
+ * @return bool
+ */
+ public function addPosition(Position $position) {
+ if (is_null($position)) {
+ return false;
+ }
+
+ $this->positions[] = $position;
+ return true;
+ }
+
+ /**
+ * @return Position[]
+ */
+ public function getPositions() {
+ return $this->positions;
+ }
}
\ No newline at end of file
diff --git a/src/Coffee/Table.php b/src/Coffee/Table.php
index 8d912e7..1999d94 100644
--- a/src/Coffee/Table.php
+++ b/src/Coffee/Table.php
@@ -14,65 +14,65 @@ namespace Coffee;
*/
class Table {
- /**
- * @var Spot[]
- */
- private $spots = [];
+ /**
+ * @var Spot[]
+ */
+ private $spots = [];
- /**
- * Table constructor.
- *
- * @param Map $map
- */
- public function __construct(Map $map) {
- foreach ($map->getTiles() as $currentTile) {
+ /**
+ * Table constructor.
+ *
+ * @param Map $map
+ */
+ public function __construct(Map $map) {
+ foreach ($map->getTiles() as $currentTile) {
- if (!$currentTile->isVisited()) {
- $currentTile->visit();
+ if (!$currentTile->isVisited()) {
+ $currentTile->visit();
- if ($currentTile->isRepresentingSpot()) {
- $spot = new Spot($currentTile->getPosition());
+ if ($currentTile->isRepresentingSpot()) {
+ $spot = new Spot($currentTile->getPosition());
- foreach ($map->getNeighboursOfTile($currentTile) as $neighbouringTile) {
- $neighbouringTile->visit();
+ foreach ($map->getNeighboursOfTile($currentTile) as $neighbouringTile) {
+ $neighbouringTile->visit();
- if ($neighbouringTile->isRepresentingSpot()) {
- $spot->addPosition($neighbouringTile->getPosition());
- }
- }
+ if ($neighbouringTile->isRepresentingSpot()) {
+ $spot->addPosition($neighbouringTile->getPosition());
+ }
+ }
- $this->addSpot($spot);
- }
- }
+ $this->addSpot($spot);
+ }
+ }
- }
- }
+ }
+ }
- /**
- * @return Spot[]
- */
- public function getSpots() {
- return $this->spots;
- }
+ /**
+ * @return Spot[]
+ */
+ public function getSpots() {
+ return $this->spots;
+ }
- /**
- * @return int
- */
- public function getSpotsCount() {
- return count($this->spots);
- }
+ /**
+ * @return int
+ */
+ public function getSpotsCount() {
+ return count($this->spots);
+ }
- /**
- * @param Spot $spot
- * @return bool
- */
- protected function addSpot(Spot $spot) {
- if (is_null($spot)) {
- return false;
- }
+ /**
+ * @param Spot $spot
+ * @return bool
+ */
+ protected function addSpot(Spot $spot) {
+ if (is_null($spot)) {
+ return false;
+ }
- $this->spots[] = $spot;
- return true;
- }
+ $this->spots[] = $spot;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/Coffee/Tile.php b/src/Coffee/Tile.php
index 789cbdd..66f2032 100644
--- a/src/Coffee/Tile.php
+++ b/src/Coffee/Tile.php
@@ -14,83 +14,84 @@ namespace Coffee;
*/
class Tile extends Position {
- /**
- * Representation on the map, that element exists on the given tile
- */
- const REPRESENTS_SPOT = 1;
- /**
- * Representation on the map, that element does not exist on the given tile
- */
- const REPRESENTS_VOID = 0;
- /**
- * @var integer
- */
- private $representation;
+ /**
+ * Representation on the map, that element exists on the given tile
+ */
+ const REPRESENTS_SPOT = 1;
+ /**
+ * Representation on the map, that element does not exist on the given tile
+ */
+ const REPRESENTS_VOID = 0;
+ /**
+ * @var integer
+ */
+ private $representation;
- /**
- * Tiles are inherently unvisited
- *
-*@var bool
- */
- private $visited = false;
+ /**
+ * Tiles are inherently unvisited
+ *
+ * @var bool
+ */
+ private $visited = false;
- /**
- * Tile constructor.
- *
- * @param $row
- * @param $column
- * @param $tileRepresentation
- * @throws \Exception
- */
- public function __construct($row, $column, $tileRepresentation) {
- if (!$this->isRepresentingSpot() && !$this->isRepresentingVoid()) {
- throw new \Exception('The map contains invalid representations');
- }
+ /**
+ * Tile constructor.
+ *
+ * @param $row
+ * @param $column
+ * @param $tileRepresentation
+ * @throws \Exception
+ */
+ public function __construct($row, $column, $tileRepresentation) {
+ if (!$this->isRepresentingSpot() && !$this->isRepresentingVoid()) {
+ throw new \Exception('The map contains invalid representations');
+ }
- parent::__construct($row, $column);
+ parent::__construct($row, $column);
- $this->representation = $tileRepresentation;
- }
+ $this->representation = $tileRepresentation;
+ }
- /**
- * @return boolean
- */
- public function isVisited() {
- return $this->visited;
- }
+ /**
+ * @return boolean
+ */
+ public function isVisited() {
+ return $this->visited;
+ }
- /**
- * Flags this Tile as "visited"
- *
- * @return bool
- */
- public function visit() {
- if ($this->isVisited())
- return false;
+ /**
+ * Flags this Tile as "visited"
+ *
+ * @return bool
+ */
+ public function visit() {
+ if ($this->isVisited()) {
+ return false;
+ }
- $this->visited = true;
- return true;
- }
+ $this->visited = true;
+ return true;
+ }
- /**
- * @return boolean
- */
- public function isRepresentingSpot() {
- return $this->representation == self::REPRESENTS_SPOT;
- }
+ /**
+ * @return boolean
+ */
+ public function isRepresentingSpot() {
+ return $this->representation == self::REPRESENTS_SPOT;
+ }
- /**
- * @return bool
- */
- public function isRepresentingVoid() {
- return $this->representation == self::REPRESENTS_VOID;
- }
+ /**
+ * @return bool
+ */
+ public function isRepresentingVoid() {
+ return $this->representation == self::REPRESENTS_VOID;
+ }
- /**
- * @return Position
- */
- public function getPosition() {
- return new Position($this->getRow(), $this->getColumn());
- }
+ /**
+ * @return Position
+ */
+ public function getPosition() {
+ return new Position($this->getRow(), $this->getColumn());
+ }
}
\ No newline at end of file
diff --git a/tests/Coffee/MapTest.php b/tests/Coffee/MapTest.php
index 33e21a8..af7f95c 100644
--- a/tests/Coffee/MapTest.php
+++ b/tests/Coffee/MapTest.php
@@ -7,119 +7,119 @@ require __DIR__ . '/../../vendor/autoload.php';
class MapTest extends \PHPUnit_Framework_TestCase {
- public function testGetTiles() {
- $tileA = new Tile(1, 1, Tile::REPRESENTS_SPOT);
- $tileB = new Tile(1, 2, Tile::REPRESENTS_VOID);
-
- $map = new Map([[1, 0]]);
- $this->assertEquals([$tileA, $tileB], $map->getTiles());
- }
-
- public function testUnvisitedTile() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
- $tiles = $map->getTiles();
- $tiles[0]->visit();
- $tiles[3]->visit();
-
- $tile = new Tile(1, 2, Tile::REPRESENTS_VOID);
-
- $this->assertEquals($tile, $map->getUnvisitedTile());
- }
-
- public function testUnVisitedTiles() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
- $tiles = $map->getTiles();
- $tiles[2]->visit();
- $tiles[3]->visit();
-
- $tileA = new Tile(1, 1, Tile::REPRESENTS_SPOT);
- $tileB = new Tile(1, 2, Tile::REPRESENTS_VOID);
-
- $this->assertEquals([$tileA, $tileB], $map->getUnvisitedTiles());
- }
-
- public function testDescribedByArray() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
- $this->assertEquals($description, $map->describedByArray());
- }
-
- public function testTileByPosition() {
- $description = [
- [1, 0],
- [0, 1],
- ];
-
- $map = new Map($description);
-
- $row = 1;
- $column = 1;
-
- $position = new Position($row, $column);
- $tile = new Tile($row, $column, Tile::REPRESENTS_SPOT);
-
- $this->assertEquals($tile, $map->getTileByPosition($position));
- }
-
- public function testHeight() {
- $description = [
- [0, 1, 0, 1],
- [1, 0, 0, 0],
- [0, 0, 0, 1],
- [0, 0, 0, 1]
- ];
-
- $map = new Map($description);
- $this->assertEquals(4, $map->getHeight());
- }
-
- public function testWidth() {
- $description = [
- [0, 1, 0, 1],
- [1, 0, 0, 0],
- [0, 0, 0, 1],
- [0, 0, 0, 1]
- ];
-
- $map = new Map($description);
- $this->assertEquals(4, $map->getWidth());
- }
-
- public function testNeighboursOfTile() {
- $description = [
- [0, 1, 0, 1],
- [1, 0, 0, 0],
- [0, 0, 0, 1],
- [0, 0, 0, 1]
- ];
-
- $map = new Map($description);
- $position = new Position(4, 4);
- $tile = $map->getTileByPosition($position);
-
- $neighbours = [
- new Tile(4, 3, Tile::REPRESENTS_VOID),
- new Tile(3, 3, Tile::REPRESENTS_VOID),
- new Tile(3, 4, Tile::REPRESENTS_SPOT),
- ];
-
- $this->assertEquals($neighbours, $map->getNeighboursOfTile($tile));
-
- }
+ public function testGetTiles() {
+ $tileA = new Tile(1, 1, Tile::REPRESENTS_SPOT);
+ $tileB = new Tile(1, 2, Tile::REPRESENTS_VOID);
+
+ $map = new Map([[1, 0]]);
+ $this->assertEquals([$tileA, $tileB], $map->getTiles());
+ }
+
+ public function testUnvisitedTile() {
+ $description = [
+ [1, 0],
+ [0, 1],
+ ];
+
+ $map = new Map($description);
+ $tiles = $map->getTiles();
+ $tiles[0]->visit();
+ $tiles[3]->visit();
+
+ $tile = new Tile(1, 2, Tile::REPRESENTS_VOID);
+
+ $this->assertEquals($tile, $map->getUnvisitedTile());
+ }
+
+ public function testUnVisitedTiles() {
+ $description = [
+ [1, 0],
+ [0, 1],
+ ];
+
+ $map = new Map($description);
+ $tiles = $map->getTiles();
+ $tiles[2]->visit();
+ $tiles[3]->visit();
+
+ $tileA = new Tile(1, 1, Tile::REPRESENTS_SPOT);
+ $tileB = new Tile(1, 2, Tile::REPRESENTS_VOID);
+
+ $this->assertEquals([$tileA, $tileB], $map->getUnvisitedTiles());
+ }
+
+ public function testDescribedByArray() {
+ $description = [
+ [1, 0],
+ [0, 1],
+ ];
+
+ $map = new Map($description);
+ $this->assertEquals($description, $map->describedByArray());
+ }
+
+ public function testTileByPosition() {
+ $description = [
+ [1, 0],
+ [0, 1],
+ ];
+
+ $map = new Map($description);
+
+ $row = 1;
+ $column = 1;
+
+ $position = new Position($row, $column);
+ $tile = new Tile($row, $column, Tile::REPRESENTS_SPOT);
+
+ $this->assertEquals($tile, $map->getTileByPosition($position));
+ }
+
+ public function testHeight() {
+ $description = [
+ [0, 1, 0, 1],
+ [1, 0, 0, 0],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+
+ $map = new Map($description);
+ $this->assertEquals(4, $map->getHeight());
+ }
+
+ public function testWidth() {
+ $description = [
+ [0, 1, 0, 1],
+ [1, 0, 0, 0],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+
+ $map = new Map($description);
+ $this->assertEquals(4, $map->getWidth());
+ }
+
+ public function testNeighboursOfTile() {
+ $description = [
+ [0, 1, 0, 1],
+ [1, 0, 0, 0],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+
+ $map = new Map($description);
+ $position = new Position(4, 4);
+ $tile = $map->getTileByPosition($position);
+
+ $neighbours = [
+ new Tile(4, 3, Tile::REPRESENTS_VOID),
+ new Tile(3, 3, Tile::REPRESENTS_VOID),
+ new Tile(3, 4, Tile::REPRESENTS_SPOT),
+ ];
+
+ $this->assertEquals($neighbours, $map->getNeighboursOfTile($tile));
+
+ }
// public function testValidPosition() {
// $description = [
diff --git a/tests/Coffee/PositionTest.php b/tests/Coffee/PositionTest.php
index 70cc3ca..6e4d9b6 100644
--- a/tests/Coffee/PositionTest.php
+++ b/tests/Coffee/PositionTest.php
@@ -51,57 +51,57 @@ class PositionTest extends \PHPUnit_Framework_TestCase {
public function testEastPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getEastPosition();
- $NorthPositionB = new Position(2, 3);
+ $northPositionB = new Position(2, 3);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testSouthEastPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthEastPosition();
- $NorthPositionB = new Position(3, 3);
+ $northPositionB = new Position(3, 3);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testSouthPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthPosition();
- $NorthPositionB = new Position(3, 2);
+ $northPositionB = new Position(3, 2);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testsSouthWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthWestPosition();
- $NorthPositionB = new Position(3, 1);
+ $northPositionB = new Position(3, 1);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getWestPosition();
- $NorthPositionB = new Position(2, 1);
+ $northPositionB = new Position(2, 1);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testNorthWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getNorthWestPosition();
- $NorthPositionB = new Position(1, 1);
+ $northPositionB = new Position(1, 1);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testNorthPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getNorthPosition();
- $NorthPositionB = new Position(1, 2);
+ $northPositionB = new Position(1, 2);
- $this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
+ $this->assertTrue($northPositionA->isTheSamePosition($northPositionB));
}
public function testOpenSpaceNeighbours() {
diff --git a/tests/Coffee/SpotTest.php b/tests/Coffee/SpotTest.php
index 27c5629..0423c1b 100644
--- a/tests/Coffee/SpotTest.php
+++ b/tests/Coffee/SpotTest.php
@@ -7,10 +7,10 @@ require __DIR__ . '/../../vendor/autoload.php';
class SpotTest extends \PHPUnit_Framework_TestCase {
- public function testGetPositions() {
- $position = new Position(2, 1);
- $spot = new Spot($position);
+ public function testGetPositions() {
+ $position = new Position(2, 1);
+ $spot = new Spot($position);
- $this->assertEquals([$position], $spot->getPositions());
- }
+ $this->assertEquals([$position], $spot->getPositions());
+ }
}
diff --git a/tests/Coffee/TableTest.php b/tests/Coffee/TableTest.php
index 9fb8cf0..12dd496 100644
--- a/tests/Coffee/TableTest.php
+++ b/tests/Coffee/TableTest.php
@@ -14,31 +14,30 @@ class TableTest extends \PHPUnit_Framework_TestCase {
// $this->assertEquals([$spot], $table->getSpots());
// }
- public function testZeroSpotsCount() {
- $description = [
- [0, 0],
- [0, 0],
- ];
-
- $map = new Map($description);
- $table = new Table($map);
-
- $this->assertEquals(0, $table->getSpotsCount());
- }
-
- public function testTwoSingleSpotsCount() {
- $description = [
- [0, 1, 0],
- [0, 0, 0],
- [1, 0, 0],
- [0, 0, 0],
- ];
-
- $map = new Map($description);
- $table = new Table($map);
-
- $this->assertEquals(2, $table->getSpotsCount());
- }
-
+ public function testZeroSpotsCount() {
+ $description = [
+ [0, 0],
+ [0, 0],
+ ];
+
+ $map = new Map($description);
+ $table = new Table($map);
+
+ $this->assertEquals(0, $table->getSpotsCount());
+ }
+
+ public function testTwoSingleSpotsCount() {
+ $description = [
+ [0, 1, 0],
+ [0, 0, 0],
+ [1, 0, 0],
+ [0, 0, 0],
+ ];
+
+ $map = new Map($description);
+ $table = new Table($map);
+
+ $this->assertEquals(2, $table->getSpotsCount());
+ }
}
diff --git a/tests/Coffee/TileTest.php b/tests/Coffee/TileTest.php
index 5ee5ccd..2ea3cb2 100644
--- a/tests/Coffee/TileTest.php
+++ b/tests/Coffee/TileTest.php
@@ -7,34 +7,34 @@ require __DIR__ . '/../../vendor/autoload.php';
class TileTest extends \PHPUnit_Framework_TestCase {
- public function testRepresentingSpot() {
- $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
+ public function testRepresentingSpot() {
+ $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
- $this->assertTrue($tile->isRepresentingSpot());
- }
+ $this->assertTrue($tile->isRepresentingSpot());
+ }
- public function testRepresentingVoid() {
- $tile = new Tile(2, 2, Tile::REPRESENTS_VOID);
+ public function testRepresentingVoid() {
+ $tile = new Tile(2, 2, Tile::REPRESENTS_VOID);
- $this->assertTrue($tile->isRepresentingVoid());
- }
+ $this->assertTrue($tile->isRepresentingVoid());
+ }
- public function testGetPosition() {
- $row = 2;
- $column = 2;
+ public function testGetPosition() {
+ $row = 2;
+ $column = 2;
- $tile = new Tile($row, $column, Tile::REPRESENTS_VOID);
- $position = new Position($row, $column);
+ $tile = new Tile($row, $column, Tile::REPRESENTS_VOID);
+ $position = new Position($row, $column);
- $this->assertEquals($position, $tile->getPosition());
+ $this->assertEquals($position, $tile->getPosition());
- }
+ }
- public function testIsVisited() {
- $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
- $tile->visit();
+ public function testIsVisited() {
+ $tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
+ $tile->visit();
- $this->assertTrue($tile->isVisited());
- }
+ $this->assertTrue($tile->isVisited());
+ }
}