From 135475e142d356bcab40ba1f5cd2e656472ec126 Mon Sep 17 00:00:00 2001 From: mdk Date: Fri, 25 Nov 2022 10:03:27 +0100 Subject: [PATCH] ref: helper::Text::superTrim --- EMS/helpers/src/Standard/Text.php | 11 ++++++++++ EMS/helpers/tests/Unit/Standard/TextTest.php | 21 ++++++++++++++++++++ elasticms-cli/src/Helper/AsyncResponse.php | 3 ++- elasticms-cli/src/Helper/TextHelper.php | 5 +++++ elasticms-cli/src/Helper/TikaWrapper.php | 3 ++- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 EMS/helpers/src/Standard/Text.php create mode 100644 EMS/helpers/tests/Unit/Standard/TextTest.php diff --git a/EMS/helpers/src/Standard/Text.php b/EMS/helpers/src/Standard/Text.php new file mode 100644 index 000000000..2262b8c73 --- /dev/null +++ b/EMS/helpers/src/Standard/Text.php @@ -0,0 +1,11 @@ +trimWhiteSpaces ? TextHelper::trim($this->getResponse()->getBody()->getContents()) : $this->getResponse()->getBody()->getContents(); + return $this->trimWhiteSpaces ? Text::superTrim($this->getResponse()->getBody()->getContents()) : $this->getResponse()->getBody()->getContents(); } public function getStream(): StreamInterface diff --git a/elasticms-cli/src/Helper/TextHelper.php b/elasticms-cli/src/Helper/TextHelper.php index 13f978ec4..11e5e8878 100644 --- a/elasticms-cli/src/Helper/TextHelper.php +++ b/elasticms-cli/src/Helper/TextHelper.php @@ -4,8 +4,13 @@ class TextHelper { + /** + * @deprecated TextHelper::trim is now deprecated, use EMS\Helpers\Standard\Text::superTrim + */ public static function trim(string $content): string { + \trigger_error('TextHelper::trim is now deprecated, use EMS\Helpers\Standard\Text::superTrim', E_USER_DEPRECATED); + return \trim(\preg_replace('!\s+!', ' ', $content) ?? ''); } } diff --git a/elasticms-cli/src/Helper/TikaWrapper.php b/elasticms-cli/src/Helper/TikaWrapper.php index ce5da555c..1739fba89 100644 --- a/elasticms-cli/src/Helper/TikaWrapper.php +++ b/elasticms-cli/src/Helper/TikaWrapper.php @@ -4,6 +4,7 @@ namespace App\Helper; +use EMS\Helpers\Standard\Text; use Psr\Http\Message\StreamInterface; class TikaWrapper extends ProcessWrapper @@ -56,7 +57,7 @@ public static function getDocumentType(StreamInterface $stream, string $cacheFol public function getOutput(): string { if ($this->trimWhiteSpaces) { - return TextHelper::trim(parent::getOutput()); + return Text::superTrim(parent::getOutput()); } return parent::getOutput();