RegExpsConfigSetting   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
c 0
b 0
f 0
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 3
1
<?php
2
/**
3
 * This file is part of the SVN-Buddy library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/console-helpers/svn-buddy
9
 */
10
11
namespace ConsoleHelpers\SVNBuddy\Config;
12
13
14
class RegExpsConfigSetting extends ArrayConfigSetting
15
{
16
17
	/**
18
	 * Performs value validation.
19
	 *
20
	 * @param mixed $value Value.
21
	 *
22
	 * @return void
23
	 * @throws \InvalidArgumentException When validation failed.
24
	 */
25 18
	protected function validate($value)
26
	{
27 18
		parent::validate($value);
28
29 18
		foreach ( $value as $regexp ) {
30 16
			if ( @preg_match($regexp, 'test') === false ) {
31 1
				throw new \InvalidArgumentException('The "' . $regexp . '" is not a valid regular expression.');
32
			}
33
		}
34
	}
35
36
}
37