Fixing style errors.

This commit is contained in:
stickler-ci 2020-03-03 09:28:00 +00:00
parent 8ce1f5f360
commit f026b959a2

View File

@ -3,14 +3,16 @@
// Learn more about this regex pattern: https://regexr.com/4vi60 // Learn more about this regex pattern: https://regexr.com/4vi60
define('HTML_REGEX_PATTERN', '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/'); define('HTML_REGEX_PATTERN', '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/');
class HtmlToOdtConverter { class HtmlToOdtConverter
{
/** /**
* Converts a string with html inside into an odt compatible string * Converts a string with html inside into an odt compatible string
* @param string The text to convert * @param string The text to convert
* @return array * @return array
*/ */
public static function htmlToOdt($htmlText) { public static function htmlToOdt($htmlText)
{
/* /*
Default styles: Default styles:
@ -59,7 +61,8 @@ class HtmlToOdtConverter {
* @param array $tags An array with html tags generated by the getDataFromHtml() function * @param array $tags An array with html tags generated by the getDataFromHtml() function
* @param array $customStyles An array of style defenitions that should be included inside the odt file * @param array $customStyles An array of style defenitions that should be included inside the odt file
*/ */
private static function replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations) { private static function replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations)
{
if ($customStyles == null) $customStyles = array(); if ($customStyles == null) $customStyles = array();
if ($fontDeclarations == null) $fontDeclarations = array(); if ($fontDeclarations == null) $fontDeclarations = array();
@ -145,7 +148,8 @@ class HtmlToOdtConverter {
* Checks if the given text is a html string * Checks if the given text is a html string
* @param string $text The text to check * @param string $text The text to check
*/ */
public static function isHtmlTag($text) { public static function isHtmlTag($text)
{
return preg_match(HTML_REGEX_PATTERN, $text); return preg_match(HTML_REGEX_PATTERN, $text);
} }
@ -153,7 +157,8 @@ class HtmlToOdtConverter {
* Checks if the given text includes a html string * Checks if the given text includes a html string
* @param string $text The text to check * @param string $text The text to check
*/ */
public static function hasHtmlTag($text) { public static function hasHtmlTag($text)
{
$result = preg_match_all(HTML_REGEX_PATTERN, $text); $result = preg_match_all(HTML_REGEX_PATTERN, $text);
return is_numeric($result) && $result > 0; return is_numeric($result) && $result > 0;
} }
@ -162,7 +167,8 @@ class HtmlToOdtConverter {
* Returns an array of html elements * Returns an array of html elements
* @param string $html A string with html tags * @param string $html A string with html tags
*/ */
private static function getDataFromHtml($html) { private static function getDataFromHtml($html)
{
$tags = array(); $tags = array();
$tempHtml = $html; $tempHtml = $html;