ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGroupNameAsMailValidator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
25
29 public function __construct(protected string $host, ?callable $group_name_check_callable = null)
30 {
31 $this->group_name_check_callable = $group_name_check_callable ?? static fn(string $group_name): bool => ilUtil::groupNameExists($group_name);
32 }
33
37 public function validate(ilMailAddress $address): bool
38 {
39 $group_name = substr($address->getMailbox(), 1);
40
42 return $func($group_name) && $this->isHostValid($address->getHost());
43 }
44
45 private function isHostValid(string $host): bool
46 {
47 return ($host === $this->host || $host === '');
48 }
49}
validate(ilMailAddress $address)
Validates if the given address contains a valid group name to send an email.
__construct(protected string $host, ?callable $group_name_check_callable=null)
static groupNameExists(string $a_group_name, ?int $a_id=null)
checks if group name already exists.