format toString separators

This commit is contained in:
yggverse 2024-06-25 03:22:08 +03:00
parent 441dc1e50a
commit 539dc97372
5 changed files with 41 additions and 10 deletions

View file

@ -58,6 +58,17 @@ class Code implements \Yggverse\Gemtext\Interface\Entity
public function toString(): string public function toString(): string
{ {
return self::TAG . $this->_alt . ($this->_inline ? self::TAG : null); return $this->_inline ? sprintf(
'%s%s%s',
self::TAG,
$this->_alt,
self::TAG
) : trim(
sprintf(
'%s %s',
self::TAG,
$this->_alt
)
);
} }
} }

View file

@ -65,9 +65,15 @@ class Header implements \Yggverse\Gemtext\Interface\Entity
public function toString(): string public function toString(): string
{ {
return str_repeat( return trim(
sprintf(
'%s %s',
str_repeat(
self::TAG, self::TAG,
$this->_level $this->_level
) . $this->_text; ),
$this->_text
)
);
} }
} }

View file

@ -116,9 +116,11 @@ class Link implements \Yggverse\Gemtext\Interface\Entity
$parts[] = $alt; $parts[] = $alt;
} }
return implode( return trim(
implode(
' ', ' ',
$parts $parts
)
); );
} }
} }

View file

@ -39,6 +39,12 @@ class Listing implements \Yggverse\Gemtext\Interface\Entity
public function toString(): string public function toString(): string
{ {
return self::TAG . ' ' . $this->_item; return trim(
sprintf(
'%s %s',
self::TAG,
$this->_item
)
);
} }
} }

View file

@ -39,6 +39,12 @@ class Quote implements \Yggverse\Gemtext\Interface\Entity
public function toString(): string public function toString(): string
{ {
return self::TAG . ' ' . $this->_text; return trim(
sprintf(
'%s %s',
self::TAG,
$this->_text
)
);
} }
} }