54 lines
1.5 KiB
PHP
Raw Normal View History

<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
2018-03-08 23:52:25 +01:00
* @copyright 2010-2018 PHPWord contributors
2014-05-04 21:03:28 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\RTF\Element;
/**
* Text element RTF writer
*
* @since 0.10.0
*/
class Text extends AbstractElement
{
/**
* Write element
2014-05-13 23:36:33 +07:00
*
* @return string
*/
public function write()
{
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
2014-05-14 00:42:05 +07:00
$element = $this->element;
$elementClass = str_replace('\\Writer\\RTF', '', get_class($this));
2018-03-18 12:37:39 +01:00
if (!$element instanceof $elementClass || !is_string($element->getText())) {
return '';
2014-05-11 19:41:48 +07:00
}
2014-05-13 23:36:33 +07:00
$this->getStyles();
2014-05-06 23:37:14 +07:00
$content = '';
2014-05-13 23:36:33 +07:00
$content .= $this->writeOpening();
$content .= '{';
2014-05-13 23:36:33 +07:00
$content .= $this->writeFontStyle();
2014-05-14 00:42:05 +07:00
$content .= $this->writeText($element->getText());
$content .= '}';
2014-05-13 23:36:33 +07:00
$content .= $this->writeClosing();
return $content;
}
}