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
ReplyToLink.php
32 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\Helper; |
| 10 | use AC\Type\Value; |
| 11 | use WP_Comment; |
| 12 | |
| 13 | class ReplyToLink implements Formatter |
| 14 | { |
| 15 | public function format(Value $value): Value |
| 16 | { |
| 17 | $comment = get_comment($value->get_id()); |
| 18 | |
| 19 | if (! $comment instanceof WP_Comment) { |
| 20 | throw ValueNotFoundException::from_id($value->get_id()); |
| 21 | } |
| 22 | |
| 23 | return $value->with_value( |
| 24 | Helper\Html::create()->link( |
| 25 | esc_url(get_comment_link($comment)), |
| 26 | get_comment_author((int)$comment->comment_ID) |
| 27 | ) |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |