domains = array_values(array_filter(array_map( static fn (string $domain): string => strtolower(trim($domain, " \t\n\r\0\x0B.@")), $domains, ))); } /** * A malformed or missing identifier is simply not an employee. It must not throw: this runs * inside the authentication path, where an exception would turn a bad address into a failed * login rather than a login without the role. */ public function isEmployee(?string $email): bool { if (null === $email || [] === $this->domains) { return false; } $position = strrpos($email, '@'); if (false === $position) { return false; } $domain = strtolower(substr($email, $position + 1)); return \in_array($domain, $this->domains, true); } }