for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\Feed;
use Exception;
use Carbon\Carbon;
use Spatie\Feed\Exceptions\InvalidFeedItem;
class FeedItem
{
/** @var string */
protected $id;
protected $title;
/** @var \Carbon\Carbon */
protected $updated;
protected $summary;
/** @var @var string */
protected $link;
protected $author;
public function __construct(array $data = [])
foreach ($data as $key => $value) {
$this->$key = $value;
}
public static function create(array $data = [])
return new static($data);
public function id(string $id)
$this->id = $id;
return $this;
public function title(string $title)
$this->title = $title;
public function updated(Carbon $updated)
$this->updated = $updated;
public function summary(string $summary)
$this->summary = $summary;
public function link(string $link)
$this->link = $link;
public function author(string $author)
$this->author = $author;
public function validate()
$requiredFields = ['id', 'title', 'updated', 'summary', 'link', 'author'];
foreach ($requiredFields as $requiredField) {
if (is_null($this->$requiredField)) {
throw InvalidFeedItem::missingField($this, $requiredField);
public function __get($key)
if (! isset($this->$key)) {
throw new Exception("Property `{$key}` doesn't exist");
return $this->$key;