Example #1
0
 /**
  * Returns the 3*3 subgrid the cell belongs too
  *
  * @return Collection
  */
 public function getSubgrid()
 {
     $xMin = $this->x - $this->x % 3;
     $xMax = $xMin + 2;
     $yMin = $this->y - $this->y % 3;
     $yMax = $yMin + 2;
     $collection = new Collection();
     for ($x = $xMin; $x <= $xMax; $x++) {
         for ($y = $yMin; $y <= $yMax; $y++) {
             $collection->addCell($this->grid->getCell($x, $y));
         }
     }
     return $collection;
 }
Example #2
0
 /**
  * Get a column by it's x coordinate (0-8)
  *
  * @param $x
  * @return Collection
  */
 public function getColumn($x)
 {
     $collection = new Collection();
     foreach ($this->cells as $cell) {
         if ($cell->getX() === $x) {
             $collection->addCell($cell);
         }
     }
     return $collection;
 }