Code Duplication    Length = 15-17 lines in 6 locations

src/Mapping/Loader/AbstractClassMetadataLoader.php 6 locations

@@ 181-195 (lines=15) @@
178
     * @param ClassMetadataInterface $classMetadata
179
     * @param string                 $xmlRoot
180
     */
181
    private function loadClassMetadataXmlRoot(ClassMetadataInterface $classMetadata, $xmlRoot)
182
    {
183
        if (!is_string($xmlRoot)) {
184
            throw new \InvalidArgumentException(sprintf(
185
                'The mapping xml root must be a non empty string, got "%s".',
186
                is_object($xmlRoot) ? get_class($xmlRoot) : gettype($xmlRoot)
187
            ));
188
        }
189
190
        if (empty($xmlRoot)) {
191
            throw new \InvalidArgumentException('The mapping xml root must be a non empty string.');
192
        }
193
194
        $classMetadata->setXmlRoot($xmlRoot);
195
    }
196
197
    /**
198
     * @param PropertyMetadataInterface $propertyMetadata
@@ 201-217 (lines=17) @@
198
     * @param PropertyMetadataInterface $propertyMetadata
199
     * @param string                    $alias
200
     */
201
    private function loadPropertyMetadataAlias(PropertyMetadataInterface $propertyMetadata, $alias)
202
    {
203
        if (!is_string($alias)) {
204
            throw new \InvalidArgumentException(sprintf(
205
                'The mapping property alias must be a non empty string, got "%s".',
206
                is_object($alias) ? get_class($alias) : gettype($alias)
207
            ));
208
        }
209
210
        $alias = trim($alias);
211
212
        if (empty($alias)) {
213
            throw new \InvalidArgumentException('The mapping property alias must be a non empty string.');
214
        }
215
216
        $propertyMetadata->setAlias($alias);
217
    }
218
219
    /**
220
     * @param PropertyMetadataInterface $propertyMetadata
@@ 239-255 (lines=17) @@
236
     * @param PropertyMetadataInterface $propertyMetadata
237
     * @param string                    $accessor
238
     */
239
    private function loadPropertyMetadataAccessor(PropertyMetadataInterface $propertyMetadata, $accessor)
240
    {
241
        if (!is_string($accessor)) {
242
            throw new \InvalidArgumentException(sprintf(
243
                'The mapping property accessor must be a non empty string, got "%s".',
244
                is_object($accessor) ? get_class($accessor) : gettype($accessor)
245
            ));
246
        }
247
248
        $accessor = trim($accessor);
249
250
        if (empty($accessor)) {
251
            throw new \InvalidArgumentException('The mapping property accessor must be a non empty string.');
252
        }
253
254
        $propertyMetadata->setAccessor($accessor);
255
    }
256
257
    /**
258
     * @param PropertyMetadataInterface $propertyMetadata
@@ 261-277 (lines=17) @@
258
     * @param PropertyMetadataInterface $propertyMetadata
259
     * @param string                    $mutator
260
     */
261
    private function loadPropertyMetadataMutator(PropertyMetadataInterface $propertyMetadata, $mutator)
262
    {
263
        if (!is_string($mutator)) {
264
            throw new \InvalidArgumentException(sprintf(
265
                'The mapping property mutator must be a non empty string, got "%s".',
266
                is_object($mutator) ? get_class($mutator) : gettype($mutator)
267
            ));
268
        }
269
270
        $mutator = trim($mutator);
271
272
        if (empty($mutator)) {
273
            throw new \InvalidArgumentException('The mapping property mutator must be a non empty string.');
274
        }
275
276
        $propertyMetadata->setMutator($mutator);
277
    }
278
279
    /**
280
     * @param PropertyMetadataInterface $propertyMetadata
@@ 283-299 (lines=17) @@
280
     * @param PropertyMetadataInterface $propertyMetadata
281
     * @param string                    $version
282
     */
283
    private function loadPropertyMetadataSinceVersion(PropertyMetadataInterface $propertyMetadata, $version)
284
    {
285
        if (!is_string($version)) {
286
            throw new \InvalidArgumentException(sprintf(
287
                'The mapping property since version must be a non empty string, got "%s".',
288
                is_object($version) ? get_class($version) : gettype($version)
289
            ));
290
        }
291
292
        $version = trim($version);
293
294
        if (empty($version)) {
295
            throw new \InvalidArgumentException('The mapping property since version must be a non empty string.');
296
        }
297
298
        $propertyMetadata->setSinceVersion($version);
299
    }
300
301
    /**
302
     * @param PropertyMetadataInterface $propertyMetadata
@@ 305-321 (lines=17) @@
302
     * @param PropertyMetadataInterface $propertyMetadata
303
     * @param string                    $version
304
     */
305
    private function loadPropertyMetadataUntilVersion(PropertyMetadataInterface $propertyMetadata, $version)
306
    {
307
        if (!is_string($version)) {
308
            throw new \InvalidArgumentException(sprintf(
309
                'The mapping property until version must be a non empty string, got "%s".',
310
                is_object($version) ? get_class($version) : gettype($version)
311
            ));
312
        }
313
314
        $version = trim($version);
315
316
        if (empty($version)) {
317
            throw new \InvalidArgumentException('The mapping property until version must be a non empty string.');
318
        }
319
320
        $propertyMetadata->setUntilVersion($version);
321
    }
322
323
    /**
324
     * @param PropertyMetadataInterface $propertyMetadata