/** * @param Layout $layout * @return array */ public function buildPageFormat(Layout $layout) { $orientation = $layout->isPortraitPage() ? 'P' : 'L'; if ($layout->isUserPaperType()) { $size = $layout->getPageSize(); } else { switch ($layout->getPagePaperType()) { case 'B4_ISO': $size = 'B4'; break; case 'B5_ISO': $size = 'B5'; break; case 'B4': $size = 'B4_JIS'; break; case 'B5': $size = 'B5_JIS'; break; default: $size = $layout->getPagePaperType(); break; } } return ['orientation' => $orientation, 'size' => $size]; }
/** * Tests for: * Layout::getLastVersion * Layout::getReportTitle * Layout::getPagePaperType * Layout::isUserPaperType * Layout::isPortraitPage * Layout::getPageSize * Layout::getSVG */ function test_getters_for_Layout_configuration() { $regular_paper_type_format = array('version' => '0.8.2', 'config' => array('title' => 'Report Title', 'page' => array('paper-type' => 'A4', 'orientation' => 'landscape')), 'svg' => '<svg></svg>'); $layout = new Layout($regular_paper_type_format, array()); $this->assertEquals('0.8.2', $layout->getLastVersion()); $this->assertEquals('Report Title', $layout->getReportTitle()); $this->assertEquals('A4', $layout->getPagePaperType()); $this->assertFalse($layout->isUserPaperType()); $this->assertFalse($layout->isPortraitPage()); $this->assertNull($layout->getPageSize()); $this->assertEquals('<svg></svg>', $layout->getSVG()); $user_paper_type_format = array('version' => '0.8.2', 'config' => array('title' => 'Report Title', 'page' => array('paper-type' => 'user', 'orientation' => 'landscape', 'width' => 100.9, 'height' => 999.9)), 'svg' => '<svg></svg>'); $layout = new Layout($user_paper_type_format, array()); $this->assertEquals('user', $layout->getPagePaperType()); $this->assertTrue($layout->isUserPaperType()); $this->assertEquals(array(100.9, 999.9), $layout->getPageSize()); }