1 | <?php |
||
36 | class ConfigurationFactory implements ConfigurationFactoryInterface |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The configuration parser factory instance used to create a parser that |
||
41 | * parsers and merges the configuration from different directories. |
||
42 | * |
||
43 | * @var \TechDivision\Import\Configuration\Jms\ConfigurationParserFactoryInterface |
||
44 | */ |
||
45 | protected $configurationParserFactory; |
||
46 | |||
47 | /** |
||
48 | * The configuration class name to use. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $configurationClassName; |
||
53 | |||
54 | /** |
||
55 | * Initializes the instance with the configuration parser factory instance. |
||
56 | * |
||
57 | * @param \TechDivision\Import\Configuration\Jms\ConfigurationParserFactoryInterface $configurationParserFactory The configuration parser factory instance |
||
58 | * @param string $configurationClass The configuration class name to use |
||
|
|||
59 | */ |
||
60 | public function __construct(ConfigurationParserFactoryInterface $configurationParserFactory, $configurationClassName = Configuration::class) |
||
65 | |||
66 | /** |
||
67 | * Return's the configuration parser factory instance. |
||
68 | * |
||
69 | * @return \TechDivision\Import\Configuration\Jms\ConfigurationParserFactoryInterface The configuration parser factory instance |
||
70 | */ |
||
71 | protected function getConfigurationParserFactory() |
||
75 | |||
76 | /** |
||
77 | * Return's the configuration class name to use. |
||
78 | * |
||
79 | * @return string The configuration class name |
||
80 | */ |
||
81 | protected function getConfigurationClassName() |
||
85 | |||
86 | /** |
||
87 | * Returns the configuration parser for the passed format. |
||
88 | * |
||
89 | * @param string $format The format of the configuration file to return the parser for (either one of json, yaml or xml) |
||
90 | * |
||
91 | * @return \TechDivision\Import\Configuration\Jms\ConfigurationParserInterface The configuration parser instance |
||
92 | */ |
||
93 | protected function getConfigurationParser($format) |
||
97 | |||
98 | /** |
||
99 | * Factory implementation to create a new initialized configuration instance. |
||
100 | * |
||
101 | * @param string $filename The configuration filename |
||
102 | * @param string $format The format of the configuration file, either one of json, yaml or xml |
||
103 | * @param string $params A serialized string with additional params that'll be passed to the configuration |
||
104 | * @param string $paramsFile A filename that contains serialized data with additional params that'll be passed to the configuration |
||
105 | * |
||
106 | * @return \TechDivision\Import\Configuration\Jms\Configuration The configuration instance |
||
107 | * @throws \Exception Is thrown, if the specified configuration file doesn't exist |
||
108 | */ |
||
109 | public function factory($filename, $format = 'json', $params = null, $paramsFile = null) |
||
121 | |||
122 | /** |
||
123 | * Factory implementation to create a new initialized configuration instance from a file |
||
124 | * with configurations that'll be parsed and merged. |
||
125 | * |
||
126 | * @param array $directories An array with diretories to parse and merge |
||
127 | * @param string $format The format of the configuration file, either one of json, yaml or xml |
||
128 | * @param string $params A serialized string with additional params that'll be passed to the configuration |
||
129 | * @param string $paramsFile A filename that contains serialized data with additional params that'll be passed to the configuration |
||
130 | * |
||
131 | * @return void |
||
132 | */ |
||
133 | public function factoryFromDirectories(array $directories = array(), $format = 'json', $params = null, $paramsFile = null) |
||
137 | |||
138 | /** |
||
139 | * Factory implementation to create a new initialized configuration instance. |
||
140 | * |
||
141 | * @param string $data The configuration data |
||
142 | * @param string $format The format of the configuration data, either one of json, yaml or xml |
||
143 | * @param string $params A serialized string with additional params that'll be passed to the configuration |
||
144 | * @param string $paramsFile A filename that contains serialized data with additional params that'll be passed to the configuration |
||
145 | * |
||
146 | * @return \TechDivision\Import\ConfigurationInterface The configuration instance |
||
147 | */ |
||
148 | public function factoryFromString($data, $format = 'json', $params = null, $paramsFile = null) |
||
181 | |||
182 | /** |
||
183 | * Creates and returns an array/object tree from the passed array. |
||
184 | * |
||
185 | * @param array $data The data to create the object tree from |
||
186 | * @param string $type The object type to create |
||
187 | * |
||
188 | * @return mixed The array/object tree from the passed array |
||
189 | */ |
||
190 | protected function fromArray(array $data, $type) |
||
194 | |||
195 | /** |
||
196 | * Deserializes the data, converts it into an array and returns it. |
||
197 | * |
||
198 | * @param string $data The data to convert |
||
199 | * @param string $type The object type for the deserialization |
||
200 | * @param string $format The data format, either one of JSON, XML or YAML |
||
201 | * |
||
202 | * @return array The data as array |
||
203 | */ |
||
204 | protected function toArray($data, $type, $format) |
||
213 | |||
214 | /** |
||
215 | * Merge the additional params in the passed configuration data and replaces existing ones with the same name. |
||
216 | * |
||
217 | * @param array $data The array with configuration data |
||
218 | * @param array $params The array with additional params to merge |
||
219 | * |
||
220 | * @return void |
||
221 | */ |
||
222 | protected function replaceParams(&$data, $params) |
||
226 | } |
||
227 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.