paragraphStyle = $this->setParagraphStyle($paragraphStyle); } /** * Get Paragraph style. * * @return \PhpOffice\PhpWord\Style\Paragraph|string */ public function getParagraphStyle() { return $this->paragraphStyle; } /** * Set Paragraph style. * * @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style * * @return \PhpOffice\PhpWord\Style\Paragraph|string */ public function setParagraphStyle($style = null) { if (is_array($style)) { $this->paragraphStyle = new Paragraph(); $this->paragraphStyle->setStyleByArray($style); } elseif ($style instanceof Paragraph) { $this->paragraphStyle = $style; } elseif (null === $style) { $this->paragraphStyle = new Paragraph(); } else { $this->paragraphStyle = $style; } return $this->paragraphStyle; } public function getText(): string { $outstr = ''; foreach ($this->getElements() as $element) { if ($element instanceof Text) { $outstr .= $element->getText(); } } return $outstr; } }