PHPWord/src/PhpWord/Escaper/AbstractEscaper.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2016-06-04 20:06:37 +04:00
<?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
2016-06-04 20:06:37 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Escaper;
/**
* @since 0.13.0
*
2016-06-04 20:06:37 +04:00
* @codeCoverageIgnore
*/
2016-06-04 20:21:54 +04:00
abstract class AbstractEscaper implements EscaperInterface
2016-06-04 20:06:37 +04:00
{
/**
2016-07-08 22:56:59 +04:00
* @param string $input
2016-06-04 20:06:37 +04:00
*
* @return string
*/
2016-07-08 22:56:59 +04:00
abstract protected function escapeSingleValue($input);
2016-06-04 20:06:37 +04:00
2016-07-08 22:56:59 +04:00
public function escape($input)
2016-06-04 20:06:37 +04:00
{
2016-07-08 22:56:59 +04:00
if (is_array($input)) {
foreach ($input as &$item) {
2016-06-04 20:06:37 +04:00
$item = $this->escapeSingleValue($item);
}
} else {
2016-07-08 22:56:59 +04:00
$input = $this->escapeSingleValue($input);
2016-06-04 20:06:37 +04:00
}
2016-07-08 22:56:59 +04:00
return $input;
2016-06-04 20:06:37 +04:00
}
}