public static function invalidType(string $type, array $allowed) : InvalidTypeException { return new static(sprintf("Invalid type \"%s\", must be one of: %s", $type, implode(", ", $allowed))); }
/** * Type constructor. * * @param string $type * * @throws InvalidTypeException */ public function __construct(string $type) { if (!in_array($type, $this->allowed, true)) { throw InvalidTypeException::invalidType($type, $this->allowed); } $this->type = $type; }