ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGroupNameAsMailValidator Class Reference

Class ilGroupNameAsMailValidator. More...

+ Collaboration diagram for ilGroupNameAsMailValidator:

Public Member Functions

 __construct (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

string $host
 
 $groupNameCheckCallable
 

Private Member Functions

 isHostValid (string $host)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $groupNameCheckCallable, $host, and ilUtil\groupNameExists().

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  }
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 57 of file class.ilGroupNameAsMailValidator.php.

Referenced by validate().

57  : bool
58  {
59  return ($host === $this->host || $host === '');
60  }
+ 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 49 of file class.ilGroupNameAsMailValidator.php.

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

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

Field Documentation

◆ $groupNameCheckCallable

ilGroupNameAsMailValidator::$groupNameCheckCallable
protected

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

Referenced by __construct(), and validate().

◆ $host

string ilGroupNameAsMailValidator::$host
protected

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

Referenced by __construct().


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