Skip to content

Commit

Permalink
chore: Run CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 3, 2024
1 parent 63410ea commit 8eb244d
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions webfiori/ui/HTMLNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,39 +760,6 @@ public static function createTextNode(string $nodeText, bool $escHtmlEntities =

return $text;
}
/**
* Removes bare line feed characters (LF) and replaces them with CRLF.
*
* A bare line feed is LF which was not preceded by a carriage return (CR).
*
* @param string $str The string to be fixed.
*
* @return string The method will return a string with all bare line feed
* characters replaced with CRLF.
*/
public static function fixBareLineFeed(string $str) : string {
$finalStr = '';
$index = 0;
$len = strlen($str);

for ($index = 0 ; $index < $len ; $index++) {
$char = $str[$index];

if ($char == "\n") {

if ($index != 0 && $str[$index - 1] != "\r") {
//Bare line feed found. Replace with \r\n
$finalStr = trim($finalStr).HTMLDoc::NL;
} else {
$finalStr .= $char;
}
} else {
$finalStr .= $char;
}
}

return $finalStr;
}

#[ReturnTypeWillChange]
/**
Expand Down Expand Up @@ -823,6 +790,38 @@ public function current() {
public function div(array $attributes = []) : HTMLNode {
return $this->addChild(new HTMLNode(), $attributes);
}
/**
* Removes bare line feed characters (LF) and replaces them with CRLF.
*
* A bare line feed is LF which was not preceded by a carriage return (CR).
*
* @param string $str The string to be fixed.
*
* @return string The method will return a string with all bare line feed
* characters replaced with CRLF.
*/
public static function fixBareLineFeed(string $str) : string {
$finalStr = '';
$index = 0;
$len = strlen($str);

for ($index = 0 ; $index < $len ; $index++) {
$char = $str[$index];

if ($char == "\n") {
if ($index != 0 && $str[$index - 1] != "\r") {
//Bare line feed found. Replace with \r\n
$finalStr = trim($finalStr).HTMLDoc::NL;

Check warning on line 814 in webfiori/ui/HTMLNode.php

View check run for this annotation

Codecov / codecov/patch

webfiori/ui/HTMLNode.php#L814

Added line #L814 was not covered by tests
} else {
$finalStr .= $char;
}
} else {
$finalStr .= $char;
}
}

return $finalStr;
}
/**
* Adds a &lt;form&gt; element to the body of the node.
*
Expand Down

0 comments on commit 8eb244d

Please sign in to comment.