PHP7 More

This commit is contained in:
Dominik Liebler
2016-09-22 18:32:37 +02:00
parent 461d612b91
commit 6ac29916c3
6 changed files with 84 additions and 191 deletions

View File

@@ -5,7 +5,7 @@ namespace DesignPatterns\More\Repository;
class Post
{
/**
* @var int
* @var int|null
*/
private $id;
@@ -19,92 +19,43 @@ class Post
*/
private $text;
/**
* @var string
*/
private $author;
public static function fromState(array $state): Post
{
return new self(
$state['id'],
$state['title'],
$state['text']
);
}
/**
* @var \DateTime
* @param int|null $id
* @param string $text
* @param string $title
*/
private $created;
public function __construct($id, string $title, string $text)
{
$this->id = $id;
$this->text = $text;
$this->title = $title;
}
/**
* @param int $id
*/
public function setId($id)
public function setId(int $id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
public function getId(): int
{
return $this->id;
}
/**
* @param string $author
*/
public function setAuthor($author)
{
$this->author = $author;
}
/**
* @return string
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param \DateTime $created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* @param string $text
*/
public function setText($text)
{
$this->text = $text;
}
/**
* @return string
*/
public function getText()
public function getText(): string
{
return $this->text;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}