ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilGroupNameAsMailValidator Class Reference

Class ilGroupNameAsMailValidator. More...

+ Collaboration diagram for ilGroupNameAsMailValidator:

Public Member Functions

 __construct (protected string $host, callable $groupNameCheckCallable=null)
 
 validate (ilMailAddress $address)
 Validates if the given address contains a valid group name to send an email. More...
 

Protected Attributes

 $groupNameCheckCallable
 

Private Member Functions

 isHostValid (string $host)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilGroupNameAsMailValidator::__construct ( protected string  $host,
callable  $groupNameCheckCallable = null 
)

Definition at line 31 of file class.ilGroupNameAsMailValidator.php.

References $groupNameCheckCallable, and ilUtil\groupNameExists().

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  }
static groupNameExists(string $a_group_name, ?int $a_id=null)
checks if group name already exists.
+ Here is the call graph for this function:

Member Function Documentation

◆ isHostValid()

ilGroupNameAsMailValidator::isHostValid ( string  $host)
private

Definition at line 53 of file class.ilGroupNameAsMailValidator.php.

Referenced by validate().

53  : bool
54  {
55  return ($host === $this->host || $host === '');
56  }
+ Here is the caller graph for this function:

◆ validate()

ilGroupNameAsMailValidator::validate ( ilMailAddress  $address)

Validates if the given address contains a valid group name to send an email.

Definition at line 45 of file class.ilGroupNameAsMailValidator.php.

References $groupNameCheckCallable, ilMailAddress\getHost(), ilMailAddress\getMailbox(), and isHostValid().

45  : bool
46  {
47  $groupName = substr($address->getMailbox(), 1);
48 
50  return $func($groupName) && $this->isHostValid($address->getHost());
51  }
+ Here is the call graph for this function:

Field Documentation

◆ $groupNameCheckCallable

ilGroupNameAsMailValidator::$groupNameCheckCallable
protected

Definition at line 29 of file class.ilGroupNameAsMailValidator.php.

Referenced by __construct(), and validate().


The documentation for this class was generated from the following file: