IntegerConfigSetting   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
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 28
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToStorageFormat() 0 3 1
A validate() 0 5 2
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 IntegerConfigSetting extends AbstractConfigSetting
15
{
16
17
	/**
18
	 * Converts value into scalar for used for storage.
19
	 *
20
	 * @param mixed $value Value.
21
	 *
22
	 * @return mixed
23
	 */
24 29
	protected function convertToStorageFormat($value)
25
	{
26 29
		return (int)$value;
27
	}
28
29
	/**
30
	 * Performs value validation.
31
	 *
32
	 * @param mixed $value Value.
33
	 *
34
	 * @return void
35
	 * @throws \InvalidArgumentException When validation failed.
36
	 */
37 14
	protected function validate($value)
38
	{
39 14
		if ( !is_numeric($value) ) {
40 4
			throw new \InvalidArgumentException(
41 4
				'The "' . $this->getName() . '" config setting value must be an integer.'
42 4
			);
43
		}
44
	}
45
46
}
47