From 3186ac6846b03137bbd0854ae9f6979a4dd6ad2b Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 28 Jul 2024 15:45:21 +0300 Subject: [PATCH] define wrap storage --- .../Browser/Container/Page/Content/Markup.php | 7 ++++--- .../Container/Page/Content/Gemtext.php | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Abstract/Entity/Browser/Container/Page/Content/Markup.php b/src/Abstract/Entity/Browser/Container/Page/Content/Markup.php index b27789a3..5a94afba 100644 --- a/src/Abstract/Entity/Browser/Container/Page/Content/Markup.php +++ b/src/Abstract/Entity/Browser/Container/Page/Content/Markup.php @@ -16,12 +16,13 @@ abstract class Markup // Dependencies public Content $content; - // Extras - protected ?string $_source = null; - // Defaults public const WRAP = 140; + // Extras + protected int $_wrap = self::WRAP; + protected ?string $_source = null; + public function __construct( Content $content ) { diff --git a/src/Entity/Browser/Container/Page/Content/Gemtext.php b/src/Entity/Browser/Container/Page/Content/Gemtext.php index 195791fb..59a1d960 100644 --- a/src/Entity/Browser/Container/Page/Content/Gemtext.php +++ b/src/Entity/Browser/Container/Page/Content/Gemtext.php @@ -315,15 +315,20 @@ class Gemtext extends Markup } private function _wrap( - string $value + string $source ): string { - return wordwrap( - $value, - $this::WRAP, - PHP_EOL, - false - ); + if ($wrap = $this->_wrap ? $this->_wrap : $this::WRAP) + { + return wordwrap( + $source, + $wrap, + PHP_EOL, + false + ); + } + + throw new Exception; } private function _url(