ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilGroupNameAsMailValidator.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 {
12  protected $host;
13 
16 
21  public function __construct(string $host, callable $groupNameCheckCallable = null)
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  }
33 
39  public function validate(\ilMailAddress $address) : 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  }
50 
56  private function isHostValid(string $host) : bool
57  {
58  return ($host == $this->host || 0 === strlen($host));
59  }
60 }
__construct(string $host, callable $groupNameCheckCallable=null)
Class ilGroupNameAsMailValidator.
isHostValid(string $host)
Checks if the given host is valid in the email context.
validate(\ilMailAddress $address)
Validates if the given address contains a valid group name to send an email.
Class ilMailAddress.