Author.php
1 day ago
CommentLink.php
1 day ago
CommentObject.php
1 day ago
CommentText.php
1 day ago
Content.php
1 day ago
LinkableCommentDate.php
1 day ago
Meta.php
1 day ago
MetaDateAndAuthor.php
1 day ago
ParentId.php
1 day ago
Property.php
1 day ago
ReplyToLink.php
1 day ago
StatusLabel.php
1 day ago
UserId.php
1 day ago
Content.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Formatter\Comment; |
| 6 | |
| 7 | use AC\Exception\ValueNotFoundException; |
| 8 | use AC\Formatter; |
| 9 | use AC\Type\Value; |
| 10 | |
| 11 | class Content implements Formatter |
| 12 | { |
| 13 | public function format(Value $value): Value |
| 14 | { |
| 15 | $comment = get_comment($value->get_id()); |
| 16 | |
| 17 | if (! $comment || ! $comment->comment_content) { |
| 18 | throw ValueNotFoundException::from_id($value->get_id()); |
| 19 | } |
| 20 | |
| 21 | return $value->with_value( |
| 22 | $comment->comment_content |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | } |
| 27 |