-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetterSetter.php
65 lines (58 loc) · 1.1 KB
/
GetterSetter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Class implements basic get/set functionality
*
* @author Vitaly Glibin
*/
class Qw_Common_GetterSetter {
/**
* Object wich contains all our properties
*
* @var stdClass
*/
protected $_object;
public function __construct()
{
$this->_object = new stdClass();
}
/**
* Setting param
*
* @param string $name parameter name
* @param mixed $value
*/
public function __set($name, $value)
{
$this->_object->{$name} = $value;
}
/**
* Getting param
*
* @param string $name
*/
public function __get($name)
{
if (isset($this->_object->{$name})) {
return $this->_object->{$name};
}
return null;
}
/**
* Check if property is set
*
* @param string $name
*/
public function __isset($name)
{
return isset($this->_object->{$name});
}
/**
* Unset property value
*
* @param string $name
*/
public function __unset($name)
{
unset($this->_object->{$name});
}
}