function testRegularTable() { $columns = new DynamicAxis(); $columns->addNames(['c0', 'c1', 'c2']); $tsection = new TableSection($columns); $tsection->addRow('r0')->td('c0', '00')->td('c1', '01')->td('c2', '02'); $tsection->addRow('r1')->td('c0', '10')->td('c1', '11')->td('c2', '12'); # print_r($tsection->getRawMatrix($columns->takeSnapshot())); }
function testNested() { $hierarchy = new DynamicAxis(); $hierarchy->addNames(['A.x', 'A.y', 'B.x']); $hierarchy->addName('A.x.22'); $this->assertEquals(['A.x' => ['A.x.22' => true], 'A' => ['A.x' => true, 'A.y' => true], 'A.y' => [], 'B.x' => [], 'B' => ['B.x' => true], 'A.x.22' => []], $hierarchy->getChildren()); $this->assertEquals(['A.x' => 'A', 'A.y' => 'A', 'B.x' => 'B', 'A' => null, 'B' => null, 'A.x.22' => 'A.x'], $hierarchy->getParents()); $this->assertEquals(['A' => true, 'B' => true], $hierarchy->getToplevelNames()); $snapshot = $hierarchy->takeSnapshot(); $this->assertEquals(['A.x.22', 'A.y', 'B.x'], $snapshot->getLeafNames()); }
/** * @param string[] $rowNames * * @return $this */ function addRowNames(array $rowNames) { $this->rows->addNames($rowNames); return $this; }
/** * @param string[] $colNames * * @return $this * @throws \Exception */ function addColNames(array $colNames) { $this->columns->addNames($colNames); return $this; }