text = SharedText::toUTF8($text); } elseif ($text instanceof TextRun) { $this->text = $text; } else { throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun'); } $this->depth = $depth; $styleName = $depth === 0 ? 'Title' : "Heading_{$this->depth}"; if (array_key_exists($styleName, Style::getStyles())) { $this->style = str_replace('_', '', $styleName); } } /** * Get Title Text content * * @return string */ public function getText() { return $this->text; } /** * Get depth * * @return int */ public function getDepth() { return $this->depth; } /** * Get Title style * * @return string */ public function getStyle() { return $this->style; } }