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

ExcludedEmailDomains   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 10 3
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
}