1 | <?php namespace BuildR\TestTools\DataSetLoader\XML\StaticType; |
||
26 | class SimpleXMLNodeTypedAttributeGetter { |
||
27 | |||
28 | /** |
||
29 | * List of available casters |
||
30 | * |
||
31 | * @type array |
||
32 | */ |
||
33 | private $casters = [ |
||
34 | 'string' => StringCaster::class, |
||
35 | 'int|integer' => IntCaster::class, |
||
36 | 'bool|boolean' => BoolCaster::class, |
||
37 | 'float|double' => FloatCaster::class, |
||
38 | 'array' => ArrayCaster::class, |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * Runtime caching |
||
43 | * |
||
44 | * @type array |
||
45 | */ |
||
46 | private $cache = []; |
||
47 | |||
48 | /** |
||
49 | * @type \SimpleXMLElement |
||
50 | */ |
||
51 | private $element; |
||
52 | |||
53 | /** |
||
54 | * SimpleXMLNodeTypedAttributeGetter constructor. |
||
55 | * This is the standard definition <dataSetProperty /> nodes. |
||
56 | * |
||
57 | * @param \SimpleXMLElement $element |
||
58 | */ |
||
59 | 3 | public function __construct(SimpleXMLElement $element) { |
|
62 | |||
63 | /** |
||
64 | * Post-processing the node value by additionally specified type |
||
65 | * declaration. If no type is defined, values returned as string. |
||
66 | * |
||
67 | * @return bool|float|int|string |
||
68 | */ |
||
69 | 3 | public function getValue() { |
|
85 | |||
86 | /** |
||
87 | * Resolve the correct caster class by defined type |
||
88 | * |
||
89 | * @param string $type |
||
90 | * |
||
91 | * @return string |
||
92 | * @throws \BuildR\TestTools\Exception\CasterException |
||
93 | */ |
||
94 | 3 | private function resolveCasterClassName($type) { |
|
107 | |||
108 | /** |
||
109 | * Try to fetch resolved type caster class from runtime cache |
||
110 | * |
||
111 | * @param string $type |
||
112 | * |
||
113 | * @return string|NULL |
||
114 | */ |
||
115 | 3 | private function tryGetClassFromCache($type) { |
|
122 | |||
123 | /** |
||
124 | * Returns the node name. If the node not defines 'name' |
||
125 | * attribute an empty string will be returned. |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 3 | public function getName() { |
|
132 | |||
133 | } |
||
134 |