Conditions | 1 |
Paths | 1 |
Total Lines | 176 |
Code Lines | 131 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
Bugs | 1 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
76 | public function shouldReadMappingData() |
||
77 | { |
||
78 | /** @var string $mappingFilePath */ |
||
79 | $mappingFilePath = __DIR__ . "/EntityExample.orm.xml"; |
||
80 | |||
81 | /** @var string $mappingImportFilePath */ |
||
82 | $mappingImportFilePath = __DIR__ . "/EntityExampleImport.orm.xml"; |
||
83 | |||
84 | $expectedMapping = new EntityMapping(EntityExample::class, [ |
||
85 | 'foo' => new ServiceMapping($this->container, 'some_service', false, "in file '{$mappingFilePath}' in line 14"), |
||
86 | 'bar' => new ServiceMapping($this->container, 'other_service', false, "in file '{$mappingFilePath}' in line 15"), |
||
87 | 'baz' => new ChoiceMapping('baz_column', [ |
||
88 | 'lorem' => new ServiceMapping($this->container, "lorem_service", false, "in file '{$mappingFilePath}' in line 19"), |
||
89 | 'ipsum' => new ServiceMapping($this->container, "ipsum_service", true, "in file '{$mappingFilePath}' in line 22"), |
||
90 | ], "in file '{$mappingFilePath}' in line 17"), |
||
91 | 'faz' => new ChoiceMapping(new Column("faz_column", Type::getType('string'), ['notnull' => true]), [ |
||
92 | 'lorem' => new ServiceMapping($this->container, "lorem_service", false, "in file '{$mappingFilePath}' in line 29"), |
||
93 | 'ipsum' => new ServiceMapping($this->container, "ipsum_service", false, "in file '{$mappingFilePath}' in line 32"), |
||
94 | ], "in file '{$mappingFilePath}' in line 26"), |
||
95 | 'far' => new ChoiceMapping(new Column("far_column", Type::getType('string'), ['notnull' => false]), [ |
||
96 | 'lorem' => new ServiceMapping($this->container, "lorem_service", false, "in file '{$mappingFilePath}' in line 42"), |
||
97 | 'ipsum' => new ServiceMapping($this->container, "ipsum_service", false, "in file '{$mappingFilePath}' in line 45"), |
||
98 | 'dolor' => new ObjectMapping( |
||
99 | ValueObjectExample::class, |
||
100 | [], |
||
101 | null, |
||
102 | "in file '{$mappingFilePath}' in line 52", |
||
103 | new CallDefinition($this->container, "createFromJson", "self", [], true, "{$mappingFilePath} in line 52"), |
||
104 | new CallDefinition($this->container, "serializeJson", null, [], false, "{$mappingFilePath} in line 52") |
||
105 | ), |
||
106 | ], "in file '{$mappingFilePath}' in line 39"), |
||
107 | 'boo' => new ObjectMapping(ValueObjectExample::class, [ |
||
108 | 'scalarValue' => new FieldMapping( |
||
109 | new Column("scalarValue", Type::getType('string'), ['notnull' => false]), |
||
110 | "in file '{$mappingFilePath}' in line 57" |
||
111 | ), |
||
112 | 'lorem' => new FieldMapping( |
||
113 | new Column("lorem", Type::getType('string'), ['notnull' => false]), |
||
114 | "in file '{$mappingFilePath}' in line 58" |
||
115 | ), |
||
116 | 'dolor' => new FieldMapping( |
||
117 | new Column("dolor", Type::getType('integer'), ['notnull' => false]), |
||
118 | "in file '{$mappingFilePath}' in line 59" |
||
119 | ), |
||
120 | ], null, "in file '{$mappingFilePath}' in line 56"), |
||
121 | 'abc' => new ObjectMapping( |
||
122 | ValueObjectExample::class, |
||
123 | [], |
||
124 | null, |
||
125 | "in file '{$mappingFilePath}' in line 67", |
||
126 | new CallDefinition($this->container, "createFromJson", "self", [], true, "{$mappingFilePath} in line 67"), |
||
127 | new CallDefinition($this->container, "serializeJson", null, [], false, "{$mappingFilePath} in line 67") |
||
128 | ), |
||
129 | 'def' => new ObjectMapping( |
||
130 | ValueObjectExample::class, |
||
131 | [ |
||
132 | 'lorem' => new FieldMapping( |
||
133 | new Column("lorem", Type::getType('string'), ['notnull' => false]), |
||
134 | "in file '{$mappingFilePath}' in line 76" |
||
135 | ), |
||
136 | 'dolor' => new FieldMapping( |
||
137 | new Column("dolor", Type::getType('integer'), ['notnull' => false]), |
||
138 | "in file '{$mappingFilePath}' in line 77" |
||
139 | ), |
||
140 | ], |
||
141 | null, |
||
142 | "in file '{$mappingFilePath}' in line 72", |
||
143 | new CallDefinition($this->container, "createValueObject", "@value_object.factory", [ |
||
144 | new FieldMapping( |
||
145 | new Column("def", Type::getType('integer'), ['notnull' => false]), |
||
146 | "in file '{$mappingFilePath}' in line 74" |
||
147 | ) |
||
148 | ], false, "{$mappingFilePath} in line 72") |
||
149 | ), |
||
150 | 'ghi' => new ObjectMapping( |
||
151 | ValueObjectExample::class, |
||
152 | [], |
||
153 | null, |
||
154 | "in file '{$mappingFilePath}' in line 83", |
||
155 | new CallDefinition($this->container, "createValueObject", "@value_object.factory", [ |
||
156 | new ChoiceMapping('baz_column', [ |
||
157 | 'lorem' => new ServiceMapping( |
||
158 | $this->container, |
||
159 | "lorem_service", |
||
160 | false, |
||
161 | "in file '{$mappingFilePath}' in line 87" |
||
162 | ), |
||
163 | 'ipsum' => new ServiceMapping( |
||
164 | $this->container, |
||
165 | "ipsum_service", |
||
166 | true, |
||
167 | "in file '{$mappingFilePath}' in line 90" |
||
168 | ), |
||
169 | ], "in file '{$mappingFilePath}' in line 85") |
||
170 | ], false, "{$mappingFilePath} in line 83") |
||
171 | ), |
||
172 | 'jkl' => new ArrayMapping( |
||
173 | [ |
||
174 | new ObjectMapping(ValueObjectExample::class, [], null, "in file '{$mappingFilePath}' in line 97"), |
||
175 | new ObjectMapping(ValueObjectExample::class, [ |
||
176 | 'qwe' => new ArrayMapping([], "in file '{$mappingFilePath}' in line 99") |
||
177 | ], null, "in file '{$mappingFilePath}' in line 98"), |
||
178 | new ObjectMapping(ValueObjectExample::class, [], null, "in file '{$mappingFilePath}' in line 101"), |
||
179 | ], |
||
180 | "in file '{$mappingFilePath}' in line 96" |
||
181 | ), |
||
182 | 'mno' => new ArrayMapping( |
||
183 | [ |
||
184 | 'foo' => new ServiceMapping( |
||
185 | $this->container, |
||
186 | 'some_service', |
||
187 | false, |
||
188 | "in file '{$mappingFilePath}' in line 106" |
||
189 | ), |
||
190 | 'bar' => new ServiceMapping( |
||
191 | $this->container, |
||
192 | 'other_service', |
||
193 | false, |
||
194 | "in file '{$mappingFilePath}' in line 109" |
||
195 | ), |
||
196 | 'baz' => new NullMapping("in file '{$mappingFilePath}' in line 113"), |
||
197 | 'maz' => new ListMapping( |
||
198 | new Column("maz_column", Type::getType('string'), ['notnull' => true]), |
||
199 | new ObjectMapping( |
||
200 | ValueObjectExample::class, |
||
201 | [], |
||
202 | new Column("maz_obj_column", Type::getType('string'), [ |
||
203 | 'length' => 255, |
||
204 | 'default' => '#DEFAULT#' |
||
205 | ]), |
||
206 | "in file '{$mappingFilePath}' in line 121" |
||
207 | ), |
||
208 | "in file '{$mappingFilePath}' in line 116" |
||
209 | ), |
||
210 | ], |
||
211 | "in file '{$mappingFilePath}' in line 104" |
||
212 | ), |
||
213 | 'pqr' => new NullableMapping( |
||
214 | new ServiceMapping($this->container, 'some_service', false, "in file '{$mappingFilePath}' in line 127"), |
||
215 | new Column("pqr_column", Type::getType('boolean'), ['notnull' => false]), |
||
216 | "in file '{$mappingFilePath}' at line 126" |
||
217 | ), |
||
218 | 'stu' => new ListMapping( |
||
219 | new Column("stu_column", Type::getType('string'), ['notnull' => true]), |
||
220 | new ObjectMapping(ValueObjectExample::class, [], null, "in file '{$mappingFilePath}' in line 131"), |
||
221 | "in file '{$mappingFilePath}' in line 130" |
||
222 | ), |
||
223 | 'vwx' => new ObjectMapping(ValueObjectExample::class, [ |
||
224 | 'foo' => new ServiceMapping( |
||
225 | $this->container, |
||
226 | 'some_service', |
||
227 | false, |
||
228 | "in file '{$mappingImportFilePath}' in line 9" |
||
229 | ), |
||
230 | 'bar' => new ServiceMapping( |
||
231 | $this->container, |
||
232 | 'other_service', |
||
233 | false, |
||
234 | "in file '{$mappingImportFilePath}' in line 10" |
||
235 | ), |
||
236 | ], new Column( |
||
237 | "vwx_column", |
||
238 | Type::getType('integer'), |
||
239 | ['notnull' => true, 'length' => 255] |
||
240 | ), "in file '{$mappingImportFilePath}' in line 8") |
||
241 | ]); |
||
242 | |||
243 | $this->fileLocator->method('fileExists')->willReturn(true); |
||
244 | $this->fileLocator->method('findMappingFile')->willReturn("@foobarbaz"); |
||
245 | |||
246 | $this->kernel->method("locateResource")->willReturn($mappingFilePath); |
||
247 | |||
248 | /** @var EntityMapping $actualMapping */ |
||
249 | $actualMapping = $this->mappingDriver->loadRDMMetadataForClass(EntityExample::class); |
||
250 | |||
251 | $this->assertEquals($expectedMapping, $actualMapping); |
||
252 | } |
||
271 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..