public function __construct(Rectangle $bounds, $level = 0) { $this->level = $level; $this->objects = []; $this->bounds = $bounds->normalized(); $this->nodes = []; }
public function testNormalized() { // All four possibilities for defining corners $rect1 = new Rectangle(0, 0, 4, 4); $rect1Norm = $rect1->normalized(); $this->assertNormalized($rect1Norm); $this->assertNotSame($rect1Norm, $rect1); $this->assertIdentical($rect1Norm, $rect1); $rect2 = new Rectangle(4, 4, 0, 0); $rect2Norm = $rect2->normalized(); $this->assertNormalized($rect2Norm); $this->assertNotSame($rect2Norm, $rect2); $this->assertIdentical($rect2Norm, $rect2); $rect3 = new Rectangle(0, 4, 4, 0); $rect3Norm = $rect3->normalized(); $this->assertNormalized($rect3Norm); $this->assertNotSame($rect3Norm, $rect3); $this->assertIdentical($rect3Norm, $rect3); $rect4 = new Rectangle(4, 0, 0, 4); $rect4Norm = $rect4->normalized(); $this->assertNormalized($rect4Norm); $this->assertNotSame($rect4Norm, $rect4); $this->assertIdentical($rect4Norm, $rect4); }