enshort variables

This commit is contained in:
yggverse 2024-06-24 05:17:11 +03:00
parent 5a953816e1
commit ccb3da8c43

View file

@ -8,7 +8,7 @@ use \Yggverse\Gemtext;
class Document class Document
{ {
private array $_entities = []; private array $_entity = [];
public function __construct( public function __construct(
string $data string $data
@ -21,7 +21,7 @@ class Document
// Code // Code
case Parser\Code::match($line): case Parser\Code::match($line):
$this->_entities[] = new Entity\Code( $this->_entity[] = new Entity\Code(
Parser\Code::getAlt( Parser\Code::getAlt(
$line $line
), ),
@ -35,7 +35,7 @@ class Document
// Header // Header
case Parser\Header::match($line): case Parser\Header::match($line):
$this->_entities[] = new Entity\Header( $this->_entity[] = new Entity\Header(
Parser\Header::getLevel( Parser\Header::getLevel(
$line $line
), ),
@ -49,7 +49,7 @@ class Document
// Link // Link
case Parser\Link::match($line): case Parser\Link::match($line):
$this->_entities[] = new Entity\Link( $this->_entity[] = new Entity\Link(
Parser\Link::getAddress( Parser\Link::getAddress(
$line $line
), ),
@ -66,7 +66,7 @@ class Document
// Listing // Listing
case Parser\Listing::match($line): case Parser\Listing::match($line):
$this->_entities[] = new Entity\Listing( $this->_entity[] = new Entity\Listing(
Parser\Listing::getItem( Parser\Listing::getItem(
$line $line
) )
@ -77,7 +77,7 @@ class Document
// Quote // Quote
case Parser\Quote::match($line): case Parser\Quote::match($line):
$this->_entities[] = new Entity\Quote( $this->_entity[] = new Entity\Quote(
Parser\Quote::getText( Parser\Quote::getText(
$line $line
) )
@ -88,7 +88,7 @@ class Document
// Plain // Plain
default: default:
$this->_entities[] = new Entity\Text( $this->_entity[] = new Entity\Text(
$line $line
); );
} }
@ -97,16 +97,16 @@ class Document
public function toString(): string public function toString(): string
{ {
$entities = []; $parts = [];
foreach ($this->_entities as $entity) foreach ($this->_entity as $entity)
{ {
$entities[] = $entity->toString(); $parts[] = $entity->toString();
} }
return implode( return implode(
PHP_EOL, PHP_EOL,
$entities $parts
); );
} }
} }