22 lines
520 B
PHP
22 lines
520 B
PHP
<?php
|
|
|
|
final class ItemParser
|
|
{
|
|
|
|
public static function parse(Post $post, string $link): Item
|
|
{
|
|
$item = new Item();
|
|
$item->title = $post->title;
|
|
$item->description = $post->content;
|
|
$item->pub_date = date("r", $post->date);
|
|
$item->url = $link .
|
|
"/?view=single&date=" . date("Y-m-d", $post->date) .
|
|
"&ref=" . $post->id;
|
|
foreach ($post->tags as $tag) {
|
|
$item->categories[] = $tag;
|
|
}
|
|
return $item;
|
|
}
|
|
|
|
}
|