_styleFont = new Font('text'); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; } $this->_styleFont->setStyleValue($key, $value); } } else { $this->_styleFont = $styleFont; } // Set paragraph style if (is_array($styleParagraph)) { $this->_styleParagraph = new Paragraph(); foreach ($styleParagraph as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; } $this->_styleParagraph->setStyleValue($key, $value); } } else { $this->_styleParagraph = $styleParagraph; } $matches = preg_split('/({.*?})/', $text, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->_text = $matches; } return $this; } /** * Get Text style * * @return \PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { return $this->_styleFont; } /** * Get Paragraph style * * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { return $this->_styleParagraph; } /** * Get Text content * * @return string */ public function getText() { return $this->_text; } }