Completed
Pull Request — master (#5586)
by Mihai
11:08
created

compositeKeyAssignedIdGeneratorRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.phpdoctrine.org>.
18
 */
19
20
namespace Doctrine\ORM\Mapping;
21
22
/**
23
 * A MappingException indicates that something is wrong with the mapping setup.
24
 *
25
 * @since 2.0
26
 */
27
class MappingException extends \Doctrine\ORM\ORMException
28
{
29
    /**
30
     * @return MappingException
31
     */
32
    public static function pathRequired()
33
    {
34
        return new self("Specifying the paths to your entities is required ".
35
            "in the AnnotationDriver to retrieve all class names.");
36
    }
37
38
    /**
39
     * @param string $entityName
40
     *
41
     * @return MappingException
42
     */
43 5
    public static function identifierRequired($entityName)
44
    {
45 5
        if (false !== ($parent = get_parent_class($entityName))) {
46 5
            return new self(sprintf(
47 5
                'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.',
48
                $entityName, $parent
49
            ));
50
        }
51
52
        return new self(sprintf(
53
            'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.',
54
            $entityName
55
        ));
56
57
    }
58
59
    /**
60
     * @param string $entityName
61
     * @param string $type
62
     *
63
     * @return MappingException
64
     */
65
    public static function invalidInheritanceType($entityName, $type)
66
    {
67
        return new self("The inheritance type '$type' specified for '$entityName' does not exist.");
68
    }
69
70
    /**
71
     * @return MappingException
72
     */
73
    public static function generatorNotAllowedWithCompositeId()
74
    {
75
        return new self("Id generators can't be used with a composite id.");
76
    }
77
78
    /**
79
     * @param string $entity
80
     *
81
     * @return MappingException
82
     */
83 1
    public static function missingFieldName($entity)
84
    {
85 1
        return new self("The field or association mapping misses the 'fieldName' attribute in entity '$entity'.");
86
    }
87
88
    /**
89
     * @param string $fieldName
90
     *
91
     * @return MappingException
92
     */
93
    public static function missingTargetEntity($fieldName)
94
    {
95
        return new self("The association mapping '$fieldName' misses the 'targetEntity' attribute.");
96
    }
97
98
    /**
99
     * @param string $fieldName
100
     *
101
     * @return MappingException
102
     */
103
    public static function missingSourceEntity($fieldName)
104
    {
105
        return new self("The association mapping '$fieldName' misses the 'sourceEntity' attribute.");
106
    }
107
108
    /**
109
     * @param string $fieldName
110
     *
111
     * @return MappingException
112
     */
113 1
    public static function missingEmbeddedClass($fieldName)
114
    {
115 1
        return new self("The embed mapping '$fieldName' misses the 'class' attribute.");
116
    }
117
118
    /**
119
     * @param string $entityName
120
     * @param string $fileName
121
     *
122
     * @return MappingException
123
     */
124
    public static function mappingFileNotFound($entityName, $fileName)
125
    {
126
        return new self("No mapping file found named '$fileName' for class '$entityName'.");
127
    }
128
129
    /**
130
     * Exception for invalid property name override.
131
     *
132
     * @param string $className The entity's name.
133
     * @param string $fieldName
134
     *
135
     * @return MappingException
136
     */
137 2
    public static function invalidOverrideFieldName($className, $fieldName)
138
    {
139 2
        return new self("Invalid field override named '$fieldName' for class '$className'.");
140
    }
141
142
    /**
143
     * Exception for invalid property type override.
144
     *
145
     * @param string $className The entity's name.
146
     * @param string $fieldName
147
     *
148
     * @return MappingException
149
     */
150 1
    public static function invalidOverrideFieldType($className, $fieldName)
151
    {
152 1
        return new self("The column type of attribute '$fieldName' on class '$className' could not be changed.");
153
    }
154
155
    /**
156
     * @param string $className
157
     * @param string $fieldName
158
     *
159
     * @return MappingException
160
     */
161 1
    public static function mappingNotFound($className, $fieldName)
162
    {
163 1
        return new self("No mapping found for field '$fieldName' on class '$className'.");
164
    }
165
166
    /**
167
     * @param string $className
168
     * @param string $queryName
169
     *
170
     * @return MappingException
171
     */
172 1
    public static function queryNotFound($className, $queryName)
173
    {
174 1
        return new self("No query found named '$queryName' on class '$className'.");
175
    }
176
177
    /**
178
     * @param string $className
179
     * @param string $resultName
180
     *
181
     * @return MappingException
182
     */
183
    public static function resultMappingNotFound($className, $resultName)
184
    {
185
        return new self("No result set mapping found named '$resultName' on class '$className'.");
186
    }
187
188
    /**
189
     * @param string $entity
190
     * @param string $queryName
191
     *
192
     * @return MappingException
193
     */
194
    public static function emptyQueryMapping($entity, $queryName)
195
    {
196
        return new self('Query named "'.$queryName.'" in "'.$entity.'" could not be empty.');
197
    }
198
199
    /**
200
     * @param string $className
201
     *
202
     * @return MappingException
203
     */
204 2
    public static function nameIsMandatoryForQueryMapping($className)
205
    {
206 2
        return new self("Query name on entity class '$className' is not defined.");
207
    }
208
209
    /**
210
     * @param string $entity
211
     * @param string $queryName
212
     *
213
     * @return MappingException
214
     */
215
    public static function missingQueryMapping($entity, $queryName)
216
    {
217
        return new self('Query named "'.$queryName.'" in "'.$entity.' requires a result class or result set mapping.');
218
    }
219
220
    /**
221
     * @param string $entity
222
     * @param string $resultName
223
     *
224
     * @return MappingException
225
     */
226 1
    public static function missingResultSetMappingEntity($entity, $resultName)
227
    {
228 1
        return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a entity class name.');
229
    }
230
231
    /**
232
     * @param string $entity
233
     * @param string $resultName
234
     *
235
     * @return MappingException
236
     */
237
    public static function missingResultSetMappingFieldName($entity, $resultName)
238
    {
239
        return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a field name.');
240
    }
241
242
    /**
243
     * @param string $className
244
     *
245
     * @return MappingException
246
     */
247
    public static function nameIsMandatoryForSqlResultSetMapping($className)
248
    {
249
        return new self("Result set mapping name on entity class '$className' is not defined.");
250
    }
251
252
    /**
253
     * @param string $fieldName
254
     *
255
     * @return MappingException
256
     */
257
    public static function oneToManyRequiresMappedBy($fieldName)
258
    {
259
        return new self("OneToMany mapping on field '$fieldName' requires the 'mappedBy' attribute.");
260
    }
261
262
    /**
263
     * @param string $fieldName
264
     *
265
     * @return MappingException
266
     */
267
    public static function joinTableRequired($fieldName)
268
    {
269
        return new self("The mapping of field '$fieldName' requires an the 'joinTable' attribute.");
270
    }
271
272
    /**
273
     * Called if a required option was not found but is required
274
     *
275
     * @param string $field          Which field cannot be processed?
276
     * @param string $expectedOption Which option is required
277
     * @param string $hint           Can optionally be used to supply a tip for common mistakes,
278
     *                               e.g. "Did you think of the plural s?"
279
     *
280
     * @return MappingException
281
     */
282
    static function missingRequiredOption($field, $expectedOption, $hint = '')
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
283
    {
284
        $message = "The mapping of field '{$field}' is invalid: The option '{$expectedOption}' is required.";
285
286
        if ( ! empty($hint)) {
287
            $message .= ' (Hint: ' . $hint . ')';
288
        }
289
290
        return new self($message);
291
    }
292
293
    /**
294
     * Generic exception for invalid mappings.
295
     *
296
     * @param string $fieldName
297
     *
298
     * @return MappingException
299
     */
300
    public static function invalidMapping($fieldName)
301
    {
302
        return new self("The mapping of field '$fieldName' is invalid.");
303
    }
304
305
    /**
306
     * Exception for reflection exceptions - adds the entity name,
307
     * because there might be long classnames that will be shortened
308
     * within the stacktrace
309
     *
310
     * @param string               $entity            The entity's name
311
     * @param \ReflectionException $previousException
312
     *
313
     * @return MappingException
314
     */
315
    public static function reflectionFailure($entity, \ReflectionException $previousException)
316
    {
317
        return new self('An error occurred in ' . $entity, 0, $previousException);
318
    }
319
320
    /**
321
     * @param string $className
322
     * @param string $joinColumn
323
     *
324
     * @return MappingException
325
     */
326
    public static function joinColumnMustPointToMappedField($className, $joinColumn)
327
    {
328
        return new self('The column ' . $joinColumn . ' must be mapped to a field in class '
329
            . $className . ' since it is referenced by a join column of another class.');
330
    }
331
332
    /**
333
     * @param string $className
334
     *
335
     * @return MappingException
336
     */
337 5
    public static function classIsNotAValidEntityOrMappedSuperClass($className)
338
    {
339 5
        if (false !== ($parent = get_parent_class($className))) {
340 3
            return new self(sprintf(
341 3
                'Class "%s" sub class of "%s" is not a valid entity or mapped super class.',
342
                $className, $parent
343
            ));
344
        }
345
346 2
        return new self(sprintf(
347 2
            'Class "%s" is not a valid entity or mapped super class.',
348
            $className
349
        ));
350
    }
351
352
    /**
353
     * @param string $className
354
     * @param string $propertyName
355
     *
356
     * @return MappingException
357
     */
358
    public static function propertyTypeIsRequired($className, $propertyName)
359
    {
360
        return new self("The attribute 'type' is required for the column description of property ".$className."::\$".$propertyName.".");
361
    }
362
363
    /**
364
     * @param string $className
365
     *
366
     * @return MappingException
367
     */
368
    public static function tableIdGeneratorNotImplemented($className)
369
    {
370
        return new self("TableIdGenerator is not yet implemented for use with class ".$className);
371
    }
372
373
    /**
374
     * @param string $entity    The entity's name.
375
     * @param string $fieldName The name of the field that was already declared.
376
     *
377
     * @return MappingException
378
     */
379 2
    public static function duplicateFieldMapping($entity, $fieldName)
380
    {
381 2
        return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once');
382
    }
383
384
    /**
385
     * @param string $entity
386
     * @param string $fieldName
387
     *
388
     * @return MappingException
389
     */
390 1
    public static function duplicateAssociationMapping($entity, $fieldName)
391
    {
392 1
        return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once');
393
    }
394
395
    /**
396
     * @param string $entity
397
     * @param string $queryName
398
     *
399
     * @return MappingException
400
     */
401 2
    public static function duplicateQueryMapping($entity, $queryName)
402
    {
403 2
        return new self('Query named "'.$queryName.'" in "'.$entity.'" was already declared, but it must be declared only once');
404
    }
405
406
    /**
407
     * @param string $entity
408
     * @param string $resultName
409
     *
410
     * @return MappingException
411
     */
412 1
    public static function duplicateResultSetMapping($entity, $resultName)
413
    {
414 1
        return new self('Result set mapping named "'.$resultName.'" in "'.$entity.'" was already declared, but it must be declared only once');
415
    }
416
417
    /**
418
     * @param string $entity
419
     *
420
     * @return MappingException
421
     */
422 1
    public static function singleIdNotAllowedOnCompositePrimaryKey($entity)
423
    {
424 1
        return new self('Single id is not allowed on composite primary key in entity '.$entity);
425
    }
426
427
    /**
428
     * @param string $entity
429
     * @param string $fieldName
430
     * @param string $unsupportedType
431
     *
432
     * @return MappingException
433
     */
434 1
    public static function unsupportedOptimisticLockingType($entity, $fieldName, $unsupportedType)
435
    {
436 1
        return new self('Locking type "'.$unsupportedType.'" (specified in "'.$entity.'", field "'.$fieldName.'") '
437 1
            .'is not supported by Doctrine.'
438
        );
439
    }
440
441
    /**
442
     * @param string|null $path
443
     *
444
     * @return MappingException
445
     */
446
    public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null)
447
    {
448
        if ( ! empty($path)) {
449
            $path = '[' . $path . ']';
450
        }
451
452
        return new self(
453
            'File mapping drivers must have a valid directory path, ' .
454
            'however the given path ' . $path . ' seems to be incorrect!'
455
        );
456
    }
457
458
    /**
459
     * Returns an exception that indicates that a class used in a discriminator map does not exist.
460
     * An example would be an outdated (maybe renamed) classname.
461
     *
462
     * @param string $className   The class that could not be found
463
     * @param string $owningClass The class that declares the discriminator map.
464
     *
465
     * @return MappingException
466
     */
467
    public static function invalidClassInDiscriminatorMap($className, $owningClass)
468
    {
469
        return new self(
470
            "Entity class '$className' used in the discriminator map of class '$owningClass' ".
471
            "does not exist."
472
        );
473
    }
474
475
    /**
476
     * @param string $className
477
     * @param array  $entries
478
     * @param array  $map
479
     *
480
     * @return MappingException
481
     */
482
    public static function duplicateDiscriminatorEntry($className, array $entries, array $map)
483
    {
484
        return new self(
485
            "The entries " . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " .
486
            "If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. " .
487
            "The entries of the current map are: @DiscriminatorMap({" . implode(', ', array_map(
488
                function($a, $b) { return "'$a': '$b'"; }, array_keys($map), array_values($map)
489
            )) . "})"
490
        );
491
    }
492
493
    /**
494
     * @param string $className
495
     *
496
     * @return MappingException
497
     */
498
    public static function missingDiscriminatorMap($className)
499
    {
500
        return new self("Entity class '$className' is using inheritance but no discriminator map was defined.");
501
    }
502
503
    /**
504
     * @param string $className
505
     *
506
     * @return MappingException
507
     */
508
    public static function missingDiscriminatorColumn($className)
509
    {
510
        return new self("Entity class '$className' is using inheritance but no discriminator column was defined.");
511
    }
512
513
    /**
514
     * @param string $className
515
     * @param string $type
516
     *
517
     * @return MappingException
518
     */
519
    public static function invalidDiscriminatorColumnType($className, $type)
520
    {
521
        return new self("Discriminator column type on entity class '$className' is not allowed to be '$type'. 'string' or 'integer' type variables are suggested!");
522
    }
523
524
    /**
525
     * @param string $className
526
     *
527
     * @return MappingException
528
     */
529 1
    public static function nameIsMandatoryForDiscriminatorColumns($className)
530
    {
531 1
        return new self("Discriminator column name on entity class '$className' is not defined.");
532
    }
533
534
    /**
535
     * @param string $className
536
     * @param string $fieldName
537
     *
538
     * @return MappingException
539
     */
540
    public static function cannotVersionIdField($className, $fieldName)
541
    {
542
        return new self("Setting Id field '$fieldName' as versionable in entity class '$className' is not supported.");
543
    }
544
545
    /**
546
     * @param string $className
547
     * @param string $fieldName
548
     * @param string $type
549
     *
550
     * @return MappingException
551
     */
552
    public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type)
553
    {
554
        return new self("It is not possible to set id field '$fieldName' to type '$type' in entity class '$className'. The type '$type' requires conversion SQL which is not allowed for identifiers.");
555
    }
556
557
    /**
558
     * @param string $className
559
     * @param string $columnName
560
     *
561
     * @return MappingException
562
     */
563 3
    public static function duplicateColumnName($className, $columnName)
564
    {
565 3
        return new self("Duplicate definition of column '".$columnName."' on entity '".$className."' in a field or discriminator column mapping.");
566
    }
567
568
    /**
569
     * @param string $className
570
     * @param string $field
571
     *
572
     * @return MappingException
573
     */
574
    public static function illegalToManyAssociationOnMappedSuperclass($className, $field)
575
    {
576
        return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '".$className."#".$field."'.");
577
    }
578
579
    /**
580
     * @param string $className
581
     * @param string $targetEntity
582
     * @param string $targetField
583
     *
584
     * @return MappingException
585
     */
586
    public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField)
587
    {
588
        return new self("It is not possible to map entity '".$className."' with a composite primary key ".
589
            "as part of the primary key of another entity '".$targetEntity."#".$targetField."'.");
590
    }
591
592
    /**
593
     * @param string $className
594
     * @param string $field
595
     *
596
     * @return MappingException
597
     */
598
    public static function noSingleAssociationJoinColumnFound($className, $field)
599
    {
600
        return new self("'$className#$field' is not an association with a single join column.");
601
    }
602
603
    /**
604
     * @param string $className
605
     * @param string $column
606
     *
607
     * @return MappingException
608
     */
609
    public static function noFieldNameFoundForColumn($className, $column)
610
    {
611
        return new self("Cannot find a field on '$className' that is mapped to column '$column'. Either the ".
612
            "field does not exist or an association exists but it has multiple join columns.");
613
    }
614
615
    /**
616
     * @param string $className
617
     * @param string $field
618
     *
619
     * @return MappingException
620
     */
621 1
    public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field)
622
    {
623 1
        return new self("The orphan removal option is not allowed on an association that is ".
624 1
            "part of the identifier in '$className#$field'.");
625
    }
626
627
    /**
628
     * @param string $className
629
     * @param string $field
630
     *
631
     * @return MappingException
632
     */
633 1
    public static function illegalOrphanRemoval($className, $field)
634
    {
635 1
        return new self("Orphan removal is only allowed on one-to-one and one-to-many ".
636 1
            "associations, but " . $className."#" .$field . " is not.");
637
    }
638
639
    /**
640
     * @param string $className
641
     * @param string $field
642
     *
643
     * @return MappingException
644
     */
645 2
    public static function illegalInverseIdentifierAssociation($className, $field)
646
    {
647 2
        return new self("An inverse association is not allowed to be identifier in '$className#$field'.");
648
    }
649
650
    /**
651
     * @param string $className
652
     * @param string $field
653
     *
654
     * @return MappingException
655
     */
656 3
    public static function illegalToManyIdentifierAssociation($className, $field)
657
    {
658 3
        return new self("Many-to-many or one-to-many associations are not allowed to be identifier in '$className#$field'.");
659
    }
660
661
    /**
662
     * @param string $className
663
     *
664
     * @return MappingException
665
     */
666
    public static function noInheritanceOnMappedSuperClass($className)
667
    {
668
        return new self("It is not supported to define inheritance information on a mapped superclass '" . $className . "'.");
669
    }
670
671
    /**
672
     * @param string $className
673
     * @param string $rootClassName
674
     *
675
     * @return MappingException
676
     */
677
    public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName)
678
    {
679
        return new self(
680
            "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " .
681
            "to be properly mapped in the inheritance hierarchy. Alternatively you can make '".$className."' an abstract class " .
682
            "to avoid this exception from occurring."
683
        );
684
    }
685
686
    /**
687
     * @param string $className
688
     * @param string $methodName
689
     *
690
     * @return MappingException
691
     */
692 1
    public static function lifecycleCallbackMethodNotFound($className, $methodName)
693
    {
694 1
        return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback.");
695
    }
696
697
    /**
698
     * @param string $listenerName
699
     * @param string $className
700
     *
701
     * @return \Doctrine\ORM\Mapping\MappingException
702
     */
703 1
    public static function entityListenerClassNotFound($listenerName, $className)
704
    {
705 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className));
706
    }
707
708
    /**
709
     * @param string $listenerName
710
     * @param string $methodName
711
     * @param string $className
712
     *
713
     * @return \Doctrine\ORM\Mapping\MappingException
714
     */
715 1
    public static function entityListenerMethodNotFound($listenerName, $methodName, $className)
716
    {
717 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName));
718
    }
719
720
    /**
721
     * @param string $listenerName
722
     * @param string $methodName
723
     * @param string $className
724
     *
725
     * @return \Doctrine\ORM\Mapping\MappingException
726
     */
727 1
    public static function duplicateEntityListener($listenerName, $methodName, $className)
728
    {
729 1
        return new self(sprintf('Entity Listener "%s#%s()" in "%s" was already declared, but it must be declared only once.', $listenerName, $methodName, $className));
730
    }
731
732
    /**
733
     * @param string $className
734
     * @param string $annotation
735
     *
736
     * @return MappingException
737
     */
738
    public static function invalidFetchMode($className, $annotation)
739
    {
740
        return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'");
741
    }
742
743
    /**
744
     * @param string $className
745
     *
746
     * @return MappingException
747
     */
748
    public static function compositeKeyAssignedIdGeneratorRequired($className)
749
    {
750
        return new self("Entity '". $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported.");
751
    }
752
753
    /**
754
     * @param string $targetEntity
755
     * @param string $sourceEntity
756
     * @param string $associationName
757
     *
758
     * @return MappingException
759
     */
760 1
    public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName)
761
    {
762 1
        return new self("The target-entity " . $targetEntity . " cannot be found in '" . $sourceEntity."#".$associationName."'.");
763
    }
764
765
    /**
766
     * @param array  $cascades
767
     * @param string $className
768
     * @param string $propertyName
769
     *
770
     * @return MappingException
771
     */
772
    public static function invalidCascadeOption(array $cascades, $className, $propertyName)
773
    {
774
        $cascades = implode(", ", array_map(function ($e) { return "'" . $e . "'"; }, $cascades));
775
776 1
        return new self(sprintf(
777 1
            "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'",
778
            $className,
779
            $propertyName,
780
            $cascades
781
        ));
782
    }
783
784
    /**
785
     * @param string $className
786
     *
787
     * @return MappingException
788
     */
789 1
    public static function missingSequenceName($className)
790
    {
791 1
        return new self(
792 1
            sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className)
793
        );
794
    }
795
796
    /**
797
     * @param string $className
798
     * @param string $propertyName
799
     *
800
     * @return MappingException
801
     */
802 2
    public static function infiniteEmbeddableNesting($className, $propertyName)
803
    {
804 2
        return new self(
805
            sprintf(
806
                'Infinite nesting detected for embedded property %s::%s. ' .
807 2
                'You cannot embed an embeddable from the same type inside an embeddable.',
808
                $className,
809
                $propertyName
810
            )
811
        );
812
    }
813
}
814