RegExpsConfigSetting::validate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

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