_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 Tab. * * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ public function toXml(XMLWriter &$xmlWriter = null) { if (isset($xmlWriter)) { $xmlWriter->startElement("w:tab"); $xmlWriter->writeAttribute("w:val", $this->_val); if (!is_null($this->_leader)) { $xmlWriter->writeAttribute("w:leader", $this->_leader); } $xmlWriter->writeAttribute("w:pos", $this->_position); $xmlWriter->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); } }