Throw an Exception if the bundle type is incorrect

This commit is contained in:
Oliver Davies 2024-01-20 09:29:53 +00:00
parent 9f175475c5
commit 2daeca7f8e

View file

@ -6,7 +6,13 @@ use Drupal\node\NodeInterface;
final class PostWrapper {
/**
* @throws \InvalidArgumentException
*/
public function __construct(private NodeInterface $post) {
if ($post->bundle() !== 'post') {
throw new \InvalidArgumentException();
}
}
public function getType(): string {