diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d531836..d1a7232 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,8 @@
-
-
-
+
-
@@ -34,11 +31,11 @@
-
+
-
-
+
+
@@ -47,8 +44,8 @@
-
-
+
+
@@ -104,11 +101,11 @@
-
+
-
-
+
+
@@ -117,8 +114,8 @@
-
-
+
+
@@ -154,16 +151,16 @@
-
-
+
+
@@ -539,38 +536,44 @@
1458154532845
-
+
+ 1458201829369
+
+
+ 1458201829369
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -579,10 +582,10 @@
-
+
-
+
@@ -978,22 +981,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1002,14 +989,6 @@
-
-
-
-
-
-
-
-
@@ -1042,10 +1021,34 @@
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index.php b/index.php
index c9f9a07..ed20410 100644
--- a/index.php
+++ b/index.php
@@ -18,8 +18,8 @@ try {
foreach ($mapRow as $mapColumnIndex => $containsCoffee) {
if ($containsCoffee == true) {
$tile = new Tile($mapColumnIndex, $mapRowIndex);
- $spot = new Spot();
- $spot->addTile($tile);
+ $spot = new Spot($tile);
+// $spot->addTile($tile);
$table->addSpot($spot);
}
diff --git a/src/Coffee/Spot.php b/src/Coffee/Spot.php
index ec61cf7..a8c746f 100644
--- a/src/Coffee/Spot.php
+++ b/src/Coffee/Spot.php
@@ -8,6 +8,11 @@
namespace Coffee;
+/**
+ * Class Spot
+ *
+ * @package Coffee
+ */
/**
* Class Spot
*
@@ -20,6 +25,27 @@ class Spot {
*/
private $tiles = [];
+ /**
+ * Spot constructor.
+ *
+ * @param Tile|Tile[] $tiles
+ */
+ public function __construct($tiles = null) {
+ if ($tiles instanceof Tile) {
+ $this->addTile($tiles);
+ }
+
+ if (is_array($tiles)) {
+ foreach ($tiles as $tile) {
+ $this->addTile($tile);
+ }
+ }
+ }
+
+ /**
+ * @param Tile $tile
+ * @return bool
+ */
public function addTile(Tile $tile) {
if (is_null($tile)) {
return false;
diff --git a/tests/SpotTest.php b/tests/SpotTest.php
index fa6596d..e40bf0c 100644
--- a/tests/SpotTest.php
+++ b/tests/SpotTest.php
@@ -9,9 +9,9 @@ class SpotTest extends \PHPUnit_Framework_TestCase {
public function testGetTiles() {
$tile = new Tile(2, 1);
- $spot = new Spot();
- $spot->addTile($tile);
+ $spot = new Spot([$tile, $tile]);
+// $spot->addTile($tile);
- $this->assertEquals([$tile], $spot->getTiles());
+ $this->assertEquals([$tile, $tile], $spot->getTiles());
}
}