Completed
Push — development ( bff125...0f5c1f )
by Fabian
07:22
created

ExcludedEmailDomains::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * integer_net Magento Module
4
 *
5
 * @category   IntegerNet
6
 * @package    IntegerNet_Anonymizer
7
 * @copyright  Copyright (c) 2016 integer_net GmbH (http://www.integer-net.de/)
8
 * @author     Fabian Schmengler <[email protected]>
9
 */
10
namespace IntegerNet\Anonymizer\Config;
11
12
/**
13
 * Can be used in entity bridge classes to exclude certain email addresses from anonymization
14
 */
15
class ExcludedEmailDomains
16
{
17
    /**
18
     * @var string[]
19
     */
20
    private $domains;
21
    public function __construct(array $domains)
22
    {
23
        $this->domains = $domains;
24
    }
25
26
    public function matches($email)
27
    {
28
        $emailDomain = preg_replace('{.*@(.*)}', '$1', $email);
29
        foreach ($this->domains as $domain) {
30
            if ($emailDomain === $domain) {
31
                return true;
32
            }
33
        }
34
        return false;
35
    }
36
}