/** * Initalize the line segment with its two endpoints. * * @api * @param \Nubs\Geometron\Point $a One endpoint of the line segment. * @param \Nubs\Geometron\Point $b One endpoint of the line segment. */ public function __construct(Point $a, Point $b) { if (!$a->isSameSpace($b)) { throw new Exception('The two points must be in the same geometric space'); } $this->_a = $a; $this->_b = $b; }
/** * Verify that 2 differently keyed points are not considered the same space. * * @test * @uses \Nubs\Geometron\Point::__construct * @uses \Nubs\Geometron\Point::vector * @covers ::isSameSpace */ public function isSameSpaceWithDifferentlyKeyedPoints() { $a = new Point(new Vector([1, 2, 3])); $b = new Point(new Vector(['x' => 5, 'y' => 7, 'z' => 2])); $this->assertFalse($a->isSameSpace($b), 'Points with different keys are not of the same space'); }