ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilGroupNameAsMailValidator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
30 
31  public function __construct(protected string $host, callable $groupNameCheckCallable = null)
32  {
33  if (null === $groupNameCheckCallable) {
34  $groupNameCheckCallable = static function (string $groupName): bool {
35  return ilUtil::groupNameExists($groupName);
36  };
37  }
38 
39  $this->groupNameCheckCallable = $groupNameCheckCallable;
40  }
41 
45  public function validate(ilMailAddress $address): bool
46  {
47  $groupName = substr($address->getMailbox(), 1);
48 
50  return $func($groupName) && $this->isHostValid($address->getHost());
51  }
52 
53  private function isHostValid(string $host): bool
54  {
55  return ($host === $this->host || $host === '');
56  }
57 }
Class ilGroupNameAsMailValidator.
__construct(protected string $host, callable $groupNameCheckCallable=null)
validate(ilMailAddress $address)
Validates if the given address contains a valid group name to send an email.
static groupNameExists(string $a_group_name, ?int $a_id=null)
checks if group name already exists.
Class ilMailAddress.