2022-11-30 14:55:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ByJoby\HTML\Containers;
|
|
|
|
|
2022-12-01 01:48:42 +00:00
|
|
|
use ByJoby\HTML\NodeInterface;
|
2022-11-30 14:55:35 +00:00
|
|
|
use ByJoby\HTML\Traits\ContainerTrait;
|
2022-12-01 01:48:42 +00:00
|
|
|
use Stringable;
|
|
|
|
use Traversable;
|
2022-11-30 14:55:35 +00:00
|
|
|
|
|
|
|
class Fragment implements FragmentInterface
|
|
|
|
{
|
|
|
|
use ContainerTrait;
|
|
|
|
|
2022-12-01 01:48:42 +00:00
|
|
|
/**
|
|
|
|
* @param null|array<mixed,string|Stringable|NodeInterface>|Traversable<mixed,string|Stringable|NodeInterface>|null $children
|
|
|
|
*/
|
|
|
|
public function __construct(null|array|Traversable $children = null)
|
|
|
|
{
|
|
|
|
if (!$children) return;
|
|
|
|
foreach ($children as $child) {
|
|
|
|
$this->addChild($child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-30 14:55:35 +00:00
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
return implode(PHP_EOL, $this->children());
|
|
|
|
}
|
|
|
|
}
|