/** * PreferredNotifyWay constructor. * @param string $value * @throws AssertException */ public function __construct($value) { Assert::assertsIsInArray($value, $this->getOptions()); $this->value = $value; }
<?php include_once __DIR__ . "/../vendor/autoload.php"; use JLaso\Assert\Assert; Assert::assertsIsAnEmail("*****@*****.**"); Assert::assertsIsAnEmail("This-is-not-an-email"); // throws an Exception
/** * Email constructor. * @param string $email * @throws AssertException */ public function __construct($email) { $email = trim(strtolower($email)); Assert::assertsIsAnEmail($email); $this->value = $email; }