Lines 100.00% 2 / 2
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
SenderHost 100.00% 2 / 2 100.00% 1 / 1 1 100.00% 1 / 1
 matches 100.00% 2 / 2 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\BankMailsParser\Parser;
6
7/**
8 * Matches a sender address against a bank domain.
9 *
10 * @internal
11 */
12final class SenderHost
13{
14    public static function matches(string $sender, string $domain): bool
15    {
16        $address = strtolower(trim($sender, " \t<>\"'"));
17
18        return preg_match('/@(?:[a-z0-9-]+\.)*' . preg_quote(strtolower($domain), '/') . '$/', $address) === 1;
19    }
20}