$title; protected $content; protected $status; // 'draft', 'published', 'archived' public function __construct($title, $content, $status) { $this->title = $title; $this->content = $content; $this->setStatus($status); } public function setStatus($status) if (!in_array($status, ['draft', 'published', 'archived'])) { throw new InvalidArgumentException('Invalid status'); } $this->status = $status; } public function getStatus(): string { return $this->status; } // 実行イメージ $blog = new BlogPost( title: 'New blog post', content: 'This is the content of the blog post.', status: PostStatus::Draft ); var_dump($blog->getStatus()); // 'draft' $blog->setStatus('published'); var_dump($blog->getStatus()); // 'published' PHP8の機能を使わないパターン