mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 15:06:31 +02:00
introduced sub-namespace Domain
This commit is contained in:
62
More/Repository/Domain/Post.php
Normal file
62
More/Repository/Domain/Post.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\More\Repository\Domain;
|
||||
|
||||
class Post
|
||||
{
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
public static function fromState(array $state): Post
|
||||
{
|
||||
return new self(
|
||||
$state['id'],
|
||||
$state['title'],
|
||||
$state['text']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
* @param string $text
|
||||
* @param string $title
|
||||
*/
|
||||
public function __construct($id, string $title, string $text)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->text = $text;
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function setId(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user