_val = (self::isStopType($val)) ? $val : 'clear'; // Default to 0 if the position is non-numeric $this->_position = (is_numeric($position)) ? intval($position) : 0; // Default to NULL if no tab leader $this->_leader = (self::isLeaderType($leader)) ? $leader : null; } /** * Creates the XML DOM for the instance of PHPWord_Style_Tab. * * @param PHPWord_Shared_XMLWriter $objWriter */ public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null) { if (isset($objWriter)) { $objWriter->startElement("w:tab"); $objWriter->writeAttribute("w:val", $this->_val); if (!is_null($this->_leader)) { $objWriter->writeAttribute("w:leader", $this->_leader); } $objWriter->writeAttribute("w:pos", $this->_position); $objWriter->endElement(); } } /** * Test if attribute is a valid stop type. * * @param string $attribute * @return bool True if it is; false otherwise. */ private static function isStopType($attribute) { return in_array($attribute, self::$_possibleStopTypes); } /** * Test if attribute is a valid leader type. * * @param string $attribute * @return bool True if it is; false otherwise. */ private static function isLeaderType($attribute) { return in_array($attribute, self::$_possibleLeaders); } }