Failed Conditions
Push — master ( d72936...c14dbc )
by Marco
14:31 queued 08:42
created

MappingException::classNotFoundInNamespaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
use Doctrine\ORM\ORMException;
8
9
/**
10
 * A MappingException indicates that something is wrong with the mapping setup.
11
 */
12
class MappingException extends ORMException
13
{
14
    /**
15
     * @return MappingException
16
     */
17
    public static function pathRequired()
18
    {
19
        return new self('Specifying the paths to your entities is required ' .
20
            'in the AnnotationDriver to retrieve all class names.');
21
    }
22
23
    /**
24
     * @param string $entityName
25
     *
26
     * @return MappingException
27
     */
28 4
    public static function identifierRequired($entityName)
29
    {
30 4
        $parent = get_parent_class($entityName);
31
32 4
        if ($parent !== false) {
0 ignored issues
show
introduced by
The condition $parent !== false can never be false.
Loading history...
33 2
            return new self(sprintf(
34 2
                'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.',
35 2
                $entityName,
36 2
                $parent
37
            ));
38
        }
39
40 2
        return new self(sprintf(
41 2
            'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.',
42 2
            $entityName
43
        ));
44
    }
45
46
    /**
47
     * @param string $entityName
48
     * @param string $type
49
     *
50
     * @return MappingException
51
     */
52
    public static function invalidInheritanceType($entityName, $type)
53
    {
54
        return new self(sprintf("The inheritance type '%s' specified for '%s' does not exist.", $type, $entityName));
55
    }
56
57
    /**
58
     * @return MappingException
59
     */
60
    public static function generatorNotAllowedWithCompositeId()
61
    {
62
        return new self("Id generators can't be used with a composite id.");
63
    }
64
65
    /**
66
     * @param string $entity
67
     *
68
     * @return MappingException
69
     */
70 1
    public static function missingFieldName($entity)
71
    {
72 1
        return new self(sprintf("The field or association mapping misses the 'fieldName' attribute in entity '%s'.", $entity));
73
    }
74
75
    /**
76
     * @param string $fieldName
77
     *
78
     * @return MappingException
79
     */
80
    public static function missingTargetEntity($fieldName)
81
    {
82
        return new self(sprintf("The association mapping '%s' misses the 'targetEntity' attribute.", $fieldName));
83
    }
84
85
    /**
86
     * @param string $fieldName
87
     *
88
     * @return MappingException
89
     */
90
    public static function missingSourceEntity($fieldName)
91
    {
92
        return new self(sprintf("The association mapping '%s' misses the 'sourceEntity' attribute.", $fieldName));
93
    }
94
95
    /**
96
     * @param string $fieldName
97
     *
98
     * @return MappingException
99
     */
100
    public static function missingEmbeddedClass($fieldName)
101
    {
102
        return new self(sprintf("The embed mapping '%s' misses the 'class' attribute.", $fieldName));
103
    }
104
105
    /**
106
     * @param string $entityName
107
     * @param string $fileName
108
     *
109
     * @return MappingException
110
     */
111
    public static function mappingFileNotFound($entityName, $fileName)
112
    {
113
        return new self(sprintf("No mapping file found named '%s' for class '%s'.", $fileName, $entityName));
114
    }
115
116
    /**
117
     * Exception for invalid property name override.
118
     *
119
     * @param string $className The entity's name.
120
     * @param string $fieldName
121
     *
122
     * @return MappingException
123
     */
124 2
    public static function invalidOverrideFieldName($className, $fieldName)
125
    {
126 2
        return new self(sprintf("Invalid field override named '%s' for class '%s'.", $fieldName, $className));
127
    }
128
129
    /**
130
     * Exception for invalid property type override.
131
     *
132
     * @param string $className The entity's name.
133
     * @param string $fieldName
134
     *
135
     * @return MappingException
136
     */
137
    public static function invalidOverridePropertyType($className, $fieldName)
138
    {
139
        return new self(sprintf("Invalid property override named '%s' for class '%s'.", $fieldName, $className));
140
    }
141
142
    /**
143
     * Exception for invalid version property override.
144
     *
145
     * @param string $className The entity's name.
146
     * @param string $fieldName
147
     *
148
     * @return MappingException
149
     */
150
    public static function invalidOverrideVersionField($className, $fieldName)
151
    {
152
        return new self(sprintf("Invalid version field override named '%s' for class '%s'.", $fieldName, $className));
153
    }
154
155
    /**
156
     * Exception for invalid property type override.
157
     *
158
     * @param string $className The entity's name.
159
     * @param string $fieldName
160
     *
161
     * @return MappingException
162
     */
163
    public static function invalidOverrideFieldType($className, $fieldName)
164
    {
165
        return new self(sprintf("The column type of attribute '%s' on class '%s' could not be changed.", $fieldName, $className));
166
    }
167
168
    /**
169
     * @param string $className
170
     * @param string $fieldName
171
     *
172
     * @return MappingException
173
     */
174
    public static function mappingNotFound($className, $fieldName)
175
    {
176
        return new self(sprintf("No mapping found for field '%s' on class '%s'.", $fieldName, $className));
177
    }
178
179
    /**
180
     * @param string $className
181
     * @param string $queryName
182
     *
183
     * @return MappingException
184
     */
185
    public static function queryNotFound($className, $queryName)
186
    {
187
        return new self(sprintf("No query found named '%s' on class '%s'.", $queryName, $className));
188
    }
189
190
    /**
191
     * @param string $className
192
     * @param string $resultName
193
     *
194
     * @return MappingException
195
     */
196
    public static function resultMappingNotFound($className, $resultName)
197
    {
198
        return new self(sprintf("No result set mapping found named '%s' on class '%s'.", $resultName, $className));
199
    }
200
201
    /**
202
     * @param string $entity
203
     * @param string $queryName
204
     *
205
     * @return MappingException
206
     */
207
    public static function missingQueryMapping($entity, $queryName)
208
    {
209
        return new self('Query named "' . $queryName . '" in "' . $entity . ' requires a result class or result set mapping.');
210
    }
211
212
    /**
213
     * @param string $entity
214
     * @param string $resultName
215
     *
216
     * @return MappingException
217
     */
218 1
    public static function missingResultSetMappingEntity($entity, $resultName)
219
    {
220 1
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a entity class name.');
221
    }
222
223
    /**
224
     * @param string $entity
225
     * @param string $resultName
226
     *
227
     * @return MappingException
228
     */
229
    public static function missingResultSetMappingFieldName($entity, $resultName)
230
    {
231
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a field name.');
232
    }
233
234
    /**
235
     * @param string $className
236
     *
237
     * @return MappingException
238
     */
239
    public static function nameIsMandatoryForSqlResultSetMapping($className)
240
    {
241
        return new self(sprintf("Result set mapping name on entity class '%s' is not defined.", $className));
242
    }
243
244
    /**
245
     * @param string $fieldName
246
     *
247
     * @return MappingException
248
     */
249
    public static function oneToManyRequiresMappedBy($fieldName)
250
    {
251
        return new self(sprintf("OneToMany mapping on field '%s' requires the 'mappedBy' attribute.", $fieldName));
252
    }
253
254
    /**
255
     * @param string $fieldName
256
     *
257
     * @return MappingException
258
     */
259
    public static function joinTableRequired($fieldName)
260
    {
261
        return new self(sprintf("The mapping of field '%s' requires an the 'joinTable' attribute.", $fieldName));
262
    }
263
264
    /**
265
     * Called if a required option was not found but is required
266
     *
267
     * @param string $field          Which field cannot be processed?
268
     * @param string $expectedOption Which option is required
269
     * @param string $hint           Can optionally be used to supply a tip for common mistakes,
270
     *                               e.g. "Did you think of the plural s?"
271
     *
272
     * @return MappingException
273
     */
274
    public static function missingRequiredOption($field, $expectedOption, $hint = '')
275
    {
276
        $message = sprintf("The mapping of field '%s' is invalid: The option '%s' is required.", $field, $expectedOption);
277
278
        if (! empty($hint)) {
279
            $message .= ' (Hint: ' . $hint . ')';
280
        }
281
282
        return new self($message);
283
    }
284
285
    /**
286
     * Generic exception for invalid mappings.
287
     *
288
     * @param string $fieldName
289
     *
290
     * @return MappingException
291
     */
292
    public static function invalidMapping($fieldName)
293
    {
294
        return new self(sprintf("The mapping of field '%s' is invalid.", $fieldName));
295
    }
296
297
    /**
298
     * Exception for reflection exceptions - adds the entity name,
299
     * because there might be long classnames that will be shortened
300
     * within the stacktrace
301
     *
302
     * @param string $entity The entity's name
303
     *
304
     * @return MappingException
305
     */
306
    public static function reflectionFailure($entity, \ReflectionException $previousException)
307
    {
308
        return new self('An error occurred in ' . $entity, 0, $previousException);
309
    }
310
311
    /**
312
     * @param string $className
313
     * @param string $joinColumn
314
     *
315
     * @return MappingException
316
     */
317
    public static function joinColumnMustPointToMappedField($className, $joinColumn)
318
    {
319
        return new self('The column ' . $joinColumn . ' must be mapped to a field in class '
320
            . $className . ' since it is referenced by a join column of another class.');
321
    }
322
323
    /**
324
     * @param string $className
325
     *
326
     * @return MappingException
327
     */
328 3
    public static function classIsNotAValidEntityOrMappedSuperClass($className)
329
    {
330 3
        $parent = get_parent_class($className);
331
332 3
        if ($parent !== false) {
0 ignored issues
show
introduced by
The condition $parent !== false can never be false.
Loading history...
333 1
            return new self(sprintf(
334 1
                'Class "%s" sub class of "%s" is not a valid entity or mapped super class.',
335 1
                $className,
336 1
                $parent
337
            ));
338
        }
339
340 2
        return new self(sprintf(
341 2
            'Class "%s" is not a valid entity or mapped super class.',
342 2
            $className
343
        ));
344
    }
345
346
    /**
347
     * @param string $className
348
     * @param string $propertyName
349
     *
350
     * @return MappingException
351
     */
352
    public static function propertyTypeIsRequired($className, $propertyName)
353
    {
354
        return new self("The attribute 'type' is required for the column description of property " . $className . '::$' . $propertyName . '.');
355
    }
356
357
    /**
358
     * @param string $className
359
     *
360
     * @return MappingException
361
     */
362
    public static function tableIdGeneratorNotImplemented($className)
363
    {
364
        return new self('TableIdGenerator is not yet implemented for use with class ' . $className);
365
    }
366
367
    /**
368
     * @param string $className
369
     *
370
     * @return MappingException
371
     */
372 3
    public static function duplicateProperty($className, Property $property)
373
    {
374 3
        return new self(sprintf(
375 3
            'Property "%s" in "%s" was already declared in "%s", but it must be declared only once',
376 3
            $property->getName(),
377 3
            $className,
378 3
            $property->getDeclaringClass()->getClassName()
379
        ));
380
    }
381
382
    /**
383
     * @param string $entity
384
     * @param string $queryName
385
     *
386
     * @return MappingException
387
     */
388 1
    public static function duplicateQueryMapping($entity, $queryName)
389
    {
390 1
        return new self('Query named "' . $queryName . '" in "' . $entity . '" was already declared, but it must be declared only once');
391
    }
392
393
    /**
394
     * @param string $entity
395
     * @param string $resultName
396
     *
397
     * @return MappingException
398
     */
399 1
    public static function duplicateResultSetMapping($entity, $resultName)
400
    {
401 1
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . '" was already declared, but it must be declared only once');
402
    }
403
404
    /**
405
     * @param string $entity
406
     *
407
     * @return MappingException
408
     */
409 1
    public static function singleIdNotAllowedOnCompositePrimaryKey($entity)
410
    {
411 1
        return new self('Single id is not allowed on composite primary key in entity ' . $entity);
412
    }
413
414
    /**
415
     * @param string $entity
416
     *
417
     * @return MappingException
418
     */
419 1
    public static function noIdDefined($entity)
420
    {
421 1
        return new self('No ID defined for entity ' . $entity);
422
    }
423
424
    /**
425
     * @param string $unsupportedType
426
     *
427
     * @return MappingException
428
     */
429 1
    public static function unsupportedOptimisticLockingType($unsupportedType)
430
    {
431 1
        return new self('Locking type "' . $unsupportedType . '" is not supported by Doctrine.');
432
    }
433
434
    /**
435
     * @param string|null $path
436
     *
437
     * @return MappingException
438
     */
439
    public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null)
440
    {
441
        if (! empty($path)) {
442
            $path = '[' . $path . ']';
443
        }
444
445
        return new self(
446
            'File mapping drivers must have a valid directory path, ' .
447
            'however the given path ' . $path . ' seems to be incorrect!'
448
        );
449
    }
450
451
    /**
452
     * Returns an exception that indicates that a class used in a discriminator map does not exist.
453
     * An example would be an outdated (maybe renamed) classname.
454
     *
455
     * @param string $className   The class that could not be found
456
     * @param string $owningClass The class that declares the discriminator map.
457
     *
458
     * @return MappingException
459
     */
460
    public static function invalidClassInDiscriminatorMap($className, $owningClass)
461
    {
462
        return new self(sprintf(
463
            "Entity class '%s' used in the discriminator map of class '%s' " .
464
            'does not exist.',
465
            $className,
466
            $owningClass
467
        ));
468
    }
469
470
    /**
471
     * @param string   $className
472
     * @param string[] $entries
473
     * @param string[] $map
474
     *
475
     * @return MappingException
476
     */
477
    public static function duplicateDiscriminatorEntry($className, array $entries, array $map)
478
    {
479
        return new self(
480
            'The entries ' . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " .
481
            'If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. ' .
482
            'The entries of the current map are: @DiscriminatorMap({' . implode(', ', array_map(
483
                function ($a, $b) {
484
                    return sprintf("'%s': '%s'", $a, $b);
485
                },
486
                array_keys($map),
487
                array_values($map)
488
            )) . '})'
489
        );
490
    }
491
492
    /**
493
     * @param string $className
494
     *
495
     * @return MappingException
496
     */
497
    public static function missingDiscriminatorMap($className)
498
    {
499
        return new self(sprintf("Entity class '%s' is using inheritance but no discriminator map was defined.", $className));
500
    }
501
502
    /**
503
     * @param string $className
504
     *
505
     * @return MappingException
506
     */
507
    public static function missingDiscriminatorColumn($className)
508
    {
509
        return new self(sprintf("Entity class '%s' is using inheritance but no discriminator column was defined.", $className));
510
    }
511
512
    /**
513
     * @param string $type
514
     *
515
     * @return MappingException
516
     */
517
    public static function invalidDiscriminatorColumnType($type)
518
    {
519
        return new self(sprintf("Discriminator column type is not allowed to be '%s'. 'string' or 'integer' type variables are suggested!", $type));
520
    }
521
522
    /**
523
     * @param string $className
524
     *
525
     * @return MappingException
526
     */
527
    public static function nameIsMandatoryForDiscriminatorColumns($className)
528
    {
529
        return new self(sprintf("Discriminator column name on entity class '%s' is not defined.", $className));
530
    }
531
532
    /**
533
     * @param string $className
534
     * @param string $fieldName
535
     *
536
     * @return MappingException
537
     */
538
    public static function cannotVersionIdField($className, $fieldName)
539
    {
540
        return new self(sprintf("Setting Id field '%s' as versionable in entity class '%s' is not supported.", $fieldName, $className));
541
    }
542
543
    /**
544
     * @param string $className
545
     *
546
     * @return MappingException
547
     */
548
    public static function sqlConversionNotAllowedForPrimaryKeyProperties($className, Property $property)
549
    {
550
        return new self(sprintf(
551
            'It is not possible to set id field "%s" to type "%s" in entity class "%s". ' .
552
            'The type "%s" requires conversion SQL which is not allowed for identifiers.',
553
            $property->getName(),
554
            $property->getTypeName(),
0 ignored issues
show
Bug introduced by
The method getTypeName() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\FieldMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

554
            $property->/** @scrutinizer ignore-call */ 
555
                       getTypeName(),
Loading history...
555
            $className,
556
            $property->getTypeName()
557
        ));
558
    }
559
560
    /**
561
     * @param string $className
562
     * @param string $fieldName
563
     * @param string $type
564
     *
565
     * @return MappingException
566
     */
567
    public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type)
568
    {
569
        return new self(sprintf(
570
            "It is not possible to set id field '%s' to type '%s' in entity class '%s'. The type '%s' "
571
                . 'requires conversion SQL which is not allowed for identifiers.',
572
            $fieldName,
573
            $type,
574
            $className,
575
            $type
576
        ));
577
    }
578
579
    /**
580
     * @param string $className
581
     * @param string $columnName
582
     *
583
     * @return MappingException
584
     */
585 3
    public static function duplicateColumnName($className, $columnName)
586
    {
587 3
        return new self("Duplicate definition of column '" . $columnName . "' on entity '" . $className . "' in a field or discriminator column mapping.");
588
    }
589
590
    /**
591
     * @param string $className
592
     * @param string $field
593
     *
594
     * @return MappingException
595
     */
596 1
    public static function illegalToManyAssociationOnMappedSuperclass($className, $field)
597
    {
598 1
        return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '" . $className . '#' . $field . "'.");
599
    }
600
601
    /**
602
     * @param string $className
603
     * @param string $targetEntity
604
     * @param string $targetField
605
     *
606
     * @return MappingException
607
     */
608
    public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField)
609
    {
610
        return new self("It is not possible to map entity '" . $className . "' with a composite primary key " .
611
            "as part of the primary key of another entity '" . $targetEntity . '#' . $targetField . "'.");
612
    }
613
614
    /**
615
     * @param string $className
616
     * @param string $field
617
     *
618
     * @return MappingException
619
     */
620
    public static function noSingleAssociationJoinColumnFound($className, $field)
621
    {
622
        return new self(sprintf("'%s#%s' is not an association with a single join column.", $className, $field));
623
    }
624
625
    /**
626
     * @param string $className
627
     * @param string $column
628
     *
629
     * @return MappingException
630
     */
631
    public static function noFieldNameFoundForColumn($className, $column)
632
    {
633
        return new self(sprintf(
634
            "Cannot find a field on '%s' that is mapped to column '%s'. Either the "
635
                . 'field does not exist or an association exists but it has multiple join columns.',
636
            $className,
637
            $column
638
        ));
639
    }
640
641
    /**
642
     * @param string $className
643
     * @param string $field
644
     *
645
     * @return MappingException
646
     */
647 1
    public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field)
648
    {
649 1
        return new self(sprintf(
650
            'The orphan removal option is not allowed on an association that is '
651 1
                . "part of the identifier in '%s#%s'.",
652 1
            $className,
653 1
            $field
654
        ));
655
    }
656
657
    /**
658
     * @param string $className
659
     * @param string $field
660
     *
661
     * @return MappingException
662
     */
663
    public static function illegalOrphanRemoval($className, $field)
664
    {
665
        return new self('Orphan removal is only allowed on one-to-one and one-to-many ' .
666
            'associations, but ' . $className . '#' . $field . ' is not.');
667
    }
668
669
    /**
670
     * @param string $className
671
     * @param string $field
672
     *
673
     * @return MappingException
674
     */
675 1
    public static function illegalInverseIdentifierAssociation($className, $field)
676
    {
677 1
        return new self(sprintf("An inverse association is not allowed to be identifier in '%s#%s'.", $className, $field));
678
    }
679
680
    /**
681
     * @param string $className
682
     * @param string $field
683
     *
684
     * @return MappingException
685
     */
686 1
    public static function illegalToManyIdentifierAssociation($className, $field)
687
    {
688 1
        return new self(sprintf("Many-to-many or one-to-many associations are not allowed to be identifier in '%s#%s'.", $className, $field));
689
    }
690
691
    /**
692
     * @param string $className
693
     *
694
     * @return MappingException
695
     */
696
    public static function noInheritanceOnMappedSuperClass($className)
697
    {
698
        return new self("It is not supported to define inheritance information on a mapped superclass '" . $className . "'.");
699
    }
700
701
    /**
702
     * @param string $className
703
     * @param string $rootClassName
704
     *
705
     * @return MappingException
706
     */
707 1
    public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName)
708
    {
709 1
        return new self(
710 1
            "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " .
711 1
            "to be properly mapped in the inheritance hierarchy. Alternatively you can make '" . $className . "' an abstract class " .
712 1
            'to avoid this exception from occurring.'
713
        );
714
    }
715
716
    /**
717
     * @param string $className
718
     * @param string $methodName
719
     *
720
     * @return MappingException
721
     */
722 1
    public static function lifecycleCallbackMethodNotFound($className, $methodName)
723
    {
724 1
        return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback.");
725
    }
726
727
    /**
728
     * @param string $listenerName
729
     * @param string $className
730
     *
731
     * @return \Doctrine\ORM\Mapping\MappingException
732
     */
733 1
    public static function entityListenerClassNotFound($listenerName, $className)
734
    {
735 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className));
736
    }
737
738
    /**
739
     * @param string $listenerName
740
     * @param string $methodName
741
     * @param string $className
742
     *
743
     * @return \Doctrine\ORM\Mapping\MappingException
744
     */
745 1
    public static function entityListenerMethodNotFound($listenerName, $methodName, $className)
746
    {
747 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName));
748
    }
749
750
    /**
751
     * @param string $listenerName
752
     * @param string $methodName
753
     * @param string $className
754
     *
755
     * @return \Doctrine\ORM\Mapping\MappingException
756
     */
757 1
    public static function duplicateEntityListener($listenerName, $methodName, $className)
758
    {
759 1
        return new self(sprintf('Entity Listener "%s#%s()" in "%s" was already declared, but it must be declared only once.', $listenerName, $methodName, $className));
760
    }
761
762
    /**
763
     * @param string $className
764
     * @param string $annotation
765
     *
766
     * @return MappingException
767
     */
768
    public static function invalidFetchMode($className, $annotation)
769
    {
770
        return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'");
771
    }
772
773
    /**
774
     * @param string $className
775
     *
776
     * @return MappingException
777
     */
778
    public static function compositeKeyAssignedIdGeneratorRequired($className)
779
    {
780
        return new self("Entity '" . $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported.");
781
    }
782
783
    /**
784
     * @param string $targetEntity
785
     * @param string $sourceEntity
786
     * @param string $associationName
787
     *
788
     * @return MappingException
789
     */
790 1
    public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName)
791
    {
792 1
        return new self("The target-entity '" . $targetEntity . "' cannot be found in '" . $sourceEntity . '#' . $associationName . "'.");
793
    }
794
795
    /**
796
     * @param string[] $cascades
797
     * @param string   $className
798
     * @param string   $propertyName
799
     *
800
     * @return MappingException
801
     */
802
    public static function invalidCascadeOption(array $cascades, $className, $propertyName)
803
    {
804 1
        $cascades = implode(', ', array_map(function ($e) {
805 1
            return "'" . $e . "'";
806 1
        }, $cascades));
807
808 1
        return new self(sprintf(
809 1
            "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', and 'refresh'",
810 1
            $className,
811 1
            $propertyName,
812 1
            $cascades
813
        ));
814
    }
815
816
    /**
817
     * @param string $className
818
     *
819
     * @return MappingException
820
     */
821
    public static function missingSequenceName($className)
822
    {
823
        return new self(
824
            sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className)
825
        );
826
    }
827
828
    /**
829
     * @param string $className
830
     * @param string $propertyName
831
     *
832
     * @return MappingException
833
     */
834
    public static function infiniteEmbeddableNesting($className, $propertyName)
835
    {
836
        return new self(
837
            sprintf(
838
                'Infinite nesting detected for embedded property %s::%s. ' .
839
                'You cannot embed an embeddable from the same type inside an embeddable.',
840
                $className,
841
                $propertyName
842
            )
843
        );
844
    }
845
846
    /**
847
     * @param string[] $namespaces
848
     */
849
    public static function classNotFoundInNamespaces(string $className, array $namespaces) : self
850
    {
851
        return new self(
852
            sprintf(
853
                'Class %s not found in namespaces %s.' .
854
                $className,
855
                implode(', ', $namespaces)
856
            )
857
        );
858
    }
859
}
860