Attachments.php
2 days ago
Author.php
2 days ago
BeforeMoreContent.php
2 days ago
CommentCount.php
2 days ago
CommentsForPostLink.php
2 days ago
ContentExcerpt.php
2 days ago
DatePublishFormatted.php
2 days ago
Depth.php
2 days ago
DescriptivePostStatus.php
2 days ago
DiscussionStatus.php
2 days ago
Excerpt.php
2 days ago
ExcerptMissingMessage.php
2 days ago
ExcerptRaw.php
2 days ago
FeaturedImage.php
2 days ago
HasCommentStatus.php
2 days ago
IsPasswordProtected.php
2 days ago
IsSticky.php
2 days ago
LastModifiedAuthor.php
2 days ago
Meta.php
2 days ago
ModifiedDate.php
2 days ago
Order.php
2 days ago
PageTemplate.php
2 days ago
Path.php
2 days ago
Permalink.php
2 days ago
PingStatus.php
2 days ago
PostContent.php
2 days ago
PostDate.php
2 days ago
PostDateTimestamp.php
2 days ago
PostFormat.php
2 days ago
PostFormatIcon.php
2 days ago
PostFormatLabel.php
2 days ago
PostLink.php
2 days ago
PostParentId.php
2 days ago
PostReferences.php
2 days ago
PostStatus.php
2 days ago
PostStatusIcon.php
2 days ago
PostTerms.php
2 days ago
PostTermsOriginal.php
2 days ago
PostTitle.php
2 days ago
Property.php
2 days ago
ShortLink.php
2 days ago
Shortcodes.php
2 days ago
Slug.php
2 days ago
ModifiedDate.php
28 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Formatter\Post; |
| 6 | |
| 7 | use AC\Exception\ValueNotFoundException; |
| 8 | use AC\Formatter; |
| 9 | use AC\Type\Value; |
| 10 | |
| 11 | class ModifiedDate implements Formatter |
| 12 | { |
| 13 | public function format(Value $value): Value |
| 14 | { |
| 15 | $post = get_post($value->get_id()); |
| 16 | $date = $post ? $post->post_modified : null; |
| 17 | |
| 18 | if (! $date) { |
| 19 | throw new ValueNotFoundException(); |
| 20 | } |
| 21 | |
| 22 | return $value->with_value( |
| 23 | strtotime($date) |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | } |
| 28 |