ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

 $host
 
 $groupNameCheckCallable
 

Private Member Functions

 isHostValid (string $host)
 Checks if the given host is valid in the email context. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $groupNameCheckCallable, and $host.

22  {
23  $this->host = $host;
24 
25  if (null === $groupNameCheckCallable) {
26  $groupNameCheckCallable = function (string $groupName) {
27  return \ilUtil::groupNameExists($groupName);
28  };
29  }
30 
31  $this->groupNameCheckCallable = $groupNameCheckCallable;
32  }

Member Function Documentation

◆ isHostValid()

ilGroupNameAsMailValidator::isHostValid ( string  $host)
private

Checks if the given host is valid in the email context.

Parameters
string$host
Returns
bool

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

Referenced by validate().

56  : bool
57  {
58  return ($host == $this->host || 0 === strlen($host));
59  }
+ 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.

Parameters
\ilMailAddress$address
Returns
bool

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

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

39  : bool
40  {
41  $groupName = substr($address->getMailbox(), 1);
42 
44  if ($func($groupName) && $this->isHostValid($address->getHost())) {
45  return true;
46  }
47 
48  return false;
49  }
isHostValid(string $host)
Checks if the given host is valid in the email context.
+ Here is the call graph for this function:

Field Documentation

◆ $groupNameCheckCallable

ilGroupNameAsMailValidator::$groupNameCheckCallable
protected

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

Referenced by __construct(), and validate().

◆ $host

ilGroupNameAsMailValidator::$host
protected

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

Referenced by __construct().


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