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