-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
764f28f
commit 346cdea
Showing
6 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Html; | ||
|
||
final class StringElement implements ElementInterface | ||
{ | ||
private $children = []; | ||
|
||
public static function create(string ...$children) | ||
{ | ||
return new static(...$children); | ||
} | ||
|
||
public function __construct(string ...$children) | ||
{ | ||
$this->children = $children; | ||
} | ||
|
||
public function __call(string $name, array $arguments): ElementInterface | ||
{ | ||
return $this; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return implode('', $this->children); | ||
} | ||
|
||
public function data(string $key, $value): ElementInterface | ||
{ | ||
return $this; | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
return [ | ||
'tag' => 'raw', | ||
'children' => $this->children, | ||
]; | ||
} | ||
|
||
public function serialize() | ||
{ | ||
return serialize($this->jsonSerialize()); | ||
} | ||
|
||
public function unserialize($data) | ||
{ | ||
$data = unserialize($data); | ||
|
||
$this->children = $data['children']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters