-
Notifications
You must be signed in to change notification settings - Fork 0
/
XmlParsingTrait.php
59 lines (53 loc) · 1.02 KB
/
XmlParsingTrait.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
<?php
/**
* @license MIT
* @license https://opensource.org/licenses/MIT The MIT License
*/
namespace Niji\XmlParserBundle;
/**
* Trait XmlParsingTrait.
*
* Adds generic getter/setter and hasProperty methods to objects,
* used by XML Parser.
*/
trait XmlParsingTrait
{
/**
* Generic getter.
*
* @param string $name
* Property name.
*
* @return mixed
* Property value.
*/
public function get(string $name)
{
return $this->{$name};
}
/**
* Generic setter.
*
* @param string $name
* Property name.
* @param mixed $value
* Property value.
*/
public function set(string $name, $value)
{
$this->{$name} = $value;
}
/**
* Check wether property exists.
*
* @param string $name
* Property name.
*
* @return bool
* TRUE if it exists, FALSE otherwise.
*/
public function hasProperty(string $name)
{
return property_exists($this, $name);
}
}