Last active
June 9, 2022 15:36
-
-
Save ismail1432/031bc84a6194ed11329255da2da542ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Article | |
{ | |
private string $status; | |
public function setStatus(string $status) | |
{ | |
$this->status = $status; | |
} | |
public function getStatus(string $status): string | |
{ | |
return $this->status; | |
} | |
} | |
class PublishArticleHandler | |
{ | |
public function __invoke(Article $article) | |
{ | |
if ($article->getStatus() === 'delted')) { | |
throw new LogicException(sprintf("Cannot mark as published as the article is deleted")); | |
} | |
} | |
$article->setStatus('published'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class PublishArticleHandler
{
public function __invoke(Article $article)
{
if ($article->getStatus() === 'delted')) {
throw new LogicException(sprintf("Cannot mark as published as the article is deleted"));
}
// } une accolade en plus ici non ?
}
}