Completed
Push — master ( 803d3c...9ccb75 )
by Josh
12:51
created

RegexpFilter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 16
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 6 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2017 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Parser\AttributeFilters;
9
10
class RegexpFilter
11
{
12
	/**
13
	* Filter a value by regexp
14
	*
15
	* @param  string $attrValue Original value
16
	* @param  string $regexp    Filtering regexp
17
	* @return mixed             Filtered value, or FALSE if invalid
18
	*/
19 28
	public static function filter($attrValue, $regexp)
20
	{
21 28
		return filter_var($attrValue, FILTER_VALIDATE_REGEXP, [
22 28
			'options' => ['regexp' => $regexp]
23
		]);
24
	}
25
}