Completed
Pull Request — master (#10)
by
unknown
01:00
created

WildcardDomain::match()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Safelist\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