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

RegexpFilter::filter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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
}