Argument::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
	* Argument.php
5
	*/
6
	
7
namespace netfocusinc\argh;
8
9
/**
10
	* Representation of a command line argument
11
	*
12
	* This class is used during the parsing process.
13
	* The ArgumentParser interprets command line arguments, and creating Arguments as they are parsed.
14
	* The resulting Arguments are them 'merged' with Parameters, assigning their values to their corresponding Parameters.
15
	*
16
	* @author Benjamin Hough
17
	*
18
	* @since 1.0.0
19
	*
20
	*/
21
class Argument
22
{
23
	
24
	//
25
	// PRIVATE PROPERTIES
26
	//
27
	
28
	/** @var string Text that uniquly identifies this Argument */ 
29
	private $key = null;
30
	
31
	/** @var mixed Data that represents this Arguments value */
32
	private $value = null;
33
	
34
	//
35
	// PUBLIC METHODS
36
	//
37
	
38
	/**
39
		* Contructs a new Argument with the specified key and value
40
		*
41
		* @since 1.0.0
42
		*/
43
	public function __construct($key=null, $value=null)
44
	{
45
		$this->key = $key;
46
		$this->value = $value;
47
	}
48
	
49
	// GETTERS/SETTERS
50
	
51
	/**
52
		* Retrieves the text 'key' that identifies this Argument
53
		*
54
		* @since 1.0.0
55
		*
56
		* @return string
57
		*/
58
	public function getKey()
59
	{ 
60
		return $this->key;
61
	}
62
	
63
	/**
64
		* Retrieves the data 'value' that belongs to this Argument
65
		*
66
		* @since 1.0.0
67
		*
68
		* @return mixed The data value of this Argument
69
		*/
70
	public function getValue()
71
	{	
72
		return $this->value;
73
	}
74
	
75
	/**
76
		* Sets the text 'key' that indentifies this Argument
77
		* 
78
		* @since 1.0.0
79
		*
80
		* @param string $key
81
		*/
82
	public function setKey(string $key)
83
	{ 
84
		$this->key = $key;
85
	}
86
87
	/**
88
		* Sets the data 'value' for this Argument
89
		* 
90
		* @since 1.0.0
91
		*
92
		* @param mixed $value
93
		*/
94
	public function setValue($value)
95
	{
96
		$this->value = $value;
97
	}
98
	
99
	/**
100
		* Returns TRUE when this Arguments 'value' is an array
101
		*
102
		* @since 1.0.0
103
		*
104
		* @return boolean
105
		*/
106
	public function isArray()
107
	{
108
		if( is_array($this->value) )
109
		{
110
			return TRUE;
111
		}
112
		else
113
		{
114
			return FALSE;
115
		}
116
	}
117
	
118
}