From 35716c4302dc29ad3b0ad5350069334aadfb527a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= <postmaster@greg0ire.fr> Date: Fri, 23 Mar 2018 22:28:16 +0100 Subject: [PATCH] Simplify first value object --- index.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/index.md b/index.md index 28a8524..be65909 100644 --- a/index.md +++ b/index.md @@ -161,7 +161,6 @@ hydrater les entités. class ArticleContent { private $content; - private $lastModification; public function __construct(string $content) { @@ -169,16 +168,10 @@ class ArticleContent throw new ArticleHasNoContent(); } $this->content = $content; - $this->lastModification = new \DatetimeImmutable(); } } ``` -Instanciation: -```php -new Article(new ArticleContent('This is a very short but nice article')); -``` - Note: - Déportation de la validation dans les value objects - Début d'arborescence @@ -200,6 +193,8 @@ class Article Instanciation: ```php +new Article(new ArticleContent('This is a very short but nice article')); +// devient Article::createFromNative('This is a very short but nice article'); ``` -- GitLab