WildcardDomain::match()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Whitelist\Definition;
4
5
/**
6
 * Represents a wildcard domain definition
7
 *
8
 * @author Sam Stenvall <[email protected]>
9
 * @copyright Copyright &copy; Sam Stenvall 2014-
10
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
11
 */
12
class WildcardDomain extends Definition
13
{
14
15
    public function validate()
16
    {
17
        return true;
18
    }
19
20
    public function match($value)
21
    {
22
        // Remove the wildcard part and check if it matches the end of $value
23
        $domain = substr($this->_definition, 1);
24
25
        return substr($value, -strlen($domain)) === $domain;
26
    }
27
28
}
29