IntegerParameter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 8 2
A getParameterType() 0 3 1
1
<?php
2
	
3
/**
4
	* IntegerParameter.php
5
	*/
6
	
7
namespace netfocusinc\argh;
8
9
use netfocusinc\argh\ArghException;
10
use netfocusinc\argh\Parameter;
11
12
13
/**
14
	* A Integer Parameter.
15
	*
16
	* Subtype of Parameter that represents an integer.
17
	*
18
	* @author Benjamin Hough
19
	*
20
	* @api
21
	*
22
	* @since 1.0.0
23
	*/
24
class IntegerParameter extends Parameter
25
{
26
	
27
	//
28
	// STATIC FUNCTIONS
29
	//
30
	
31
	//
32
	// PUBLIC FUNCTIONS
33
	//
34
	
35
	/**
36
		* Returns one of the ARGH_TYPE_INT
37
		*
38
		* @since 1.0.0
39
		*
40
		* @return int
41
		*/
42
	public function getParameterType(): int
43
	{
44
		return Parameter::ARGH_TYPE_INT;
45
	}
46
47
	/**
48
		* Sets the int value of this Parameter.
49
		*
50
		* Casts all values to int.
51
		*
52
		* @since 1.0.0
53
		*
54
		* @return int
55
		*/
56
	public function setValue($value)
57
	{		
58
		if(!is_numeric($value))
59
		{
60
			throw(new ArghException('IntegerParameter values must be numeric'));
61
		}
62
		
63
		$this->value = intval($value);
64
	}
65
	
66
}
67