Esempio n. 1
0
 /**
  * Compare a provided coordinate against this one.
  * @param  Coordinate $comparison
  * @return int      Uses standard <=> style return values.
  */
 public function compareTo(Coordinate $comparison) : int
 {
     if ($comparison->x() < $this->x() || $comparison->y() < $this->y()) {
         return -1;
     }
     if ($comparison->x() > $this->x() || $comparison->y() > $this->y()) {
         return 1;
     }
     return 0;
 }
Esempio n. 2
0
 /**
  * @dataProvider invalidProvider
  * @expectedException HelloFresh\Ausraster\Exception\InvalidCoordinateException
  */
 public function testCreatingInvalidCoordinate($x, $y)
 {
     $coordinate = new Coordinate($x, $y);
     $x = strtoupper($x);
     $this->assertEquals($x, $coordinate->x());
     $this->assertEquals($y, $coordinate->y());
     $this->assertEquals($x . $y, (string) $coordinate);
 }
Esempio n. 3
0
 /**
  * Count the number of cells in the range
  * @return int
  */
 public function count() : int
 {
     $rangeX = ord($this->to->x()) - ord($this->from->x());
     $rangeY = $this->to->y() - $this->from->y();
     return ++$rangeX * ++$rangeY;
 }