1 | <?php |
||
36 | class ConfigurationFactory implements ConfigurationFactoryInterface |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * Factory implementation to create a new initialized configuration instance. |
||
41 | * |
||
42 | * @param string $filename The configuration filename |
||
43 | * @param string $format The format of the configuration file, either one of json, yaml or xml |
||
44 | * @param string $params A serialized string with additional params that'll be passed to the configuration |
||
45 | * @param string $paramsFile A filename that contains serialized data with additional params that'll be passed to the configuration |
||
46 | * |
||
47 | * @return \TechDivision\Import\Configuration\Jms\Configuration The configuration instance |
||
48 | * @throws \Exception Is thrown, if the specified configuration file doesn't exist |
||
49 | */ |
||
50 | public function factory($filename, $format = 'json', $params = null, $paramsFile = null) |
||
62 | |||
63 | /** |
||
64 | * Factory implementation to create a new initialized configuration instance. |
||
65 | * |
||
66 | * @param string $data The configuration data |
||
67 | * @param string $format The format of the configuration data, either one of json, yaml or xml |
||
68 | * @param string $params A serialized string with additional params that'll be passed to the configuration |
||
69 | * @param string $paramsFile A filename that contains serialized data with additional params that'll be passed to the configuration |
||
70 | * |
||
71 | * @return \TechDivision\Import\Configuration\Jms\Configuration The configuration instance |
||
72 | */ |
||
73 | public function factoryFromString($data, $format = 'json', $params = null, $paramsFile = null) |
||
106 | |||
107 | /** |
||
108 | * Creates and returns an array/object tree from the passed array. |
||
109 | * |
||
110 | * @param array $data The data to create the object tree from |
||
111 | * @param string $type The object type to create |
||
112 | * |
||
113 | * @return mixed The array/object tree from the passed array |
||
114 | */ |
||
115 | protected function fromArray(array $data, $type) |
||
119 | |||
120 | /** |
||
121 | * Deserializes the data, converts it into an array and returns it. |
||
122 | * |
||
123 | * @param string $data The data to convert |
||
124 | * @param string $type The object type for the deserialization |
||
125 | * @param string $format The data format, either one of JSON, XML or YAML |
||
126 | * |
||
127 | * @return array The data as array |
||
128 | */ |
||
129 | protected function toArray($data, $type, $format) |
||
138 | |||
139 | /** |
||
140 | * Merge the additional params in the passed configuration data. |
||
141 | * |
||
142 | * @param array $data The array with configuration data |
||
143 | * @param array $params The array with additional params to merge |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | protected function mergeParams(&$data, $params) |
||
163 | } |
||
164 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: