Failed Conditions
Pull Request — develop (#6873)
by
unknown
112:44 queued 47:41
created

classIsNotAValidEntityOrMappedSuperClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 1
CRAP Score 3.1852

Importance

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

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