vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php line 13

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Persistence\Mapping;
  3. use Exception;
  4. use function implode;
  5. use function sprintf;
  6. /**
  7.  * A MappingException indicates that something is wrong with the mapping setup.
  8.  */
  9. class MappingException extends Exception
  10. {
  11.     /**
  12.      * @param string   $className
  13.      * @param string[] $namespaces
  14.      *
  15.      * @return self
  16.      */
  17.     public static function classNotFoundInNamespaces($className$namespaces)
  18.     {
  19.         return new self(sprintf(
  20.             "The class '%s' was not found in the chain configured namespaces %s",
  21.             $className,
  22.             implode(', '$namespaces)
  23.         ));
  24.     }
  25.     /**
  26.      * @deprecated Use pathRequiredForDriver instead
  27.      *
  28.      * @return self
  29.      */
  30.     public static function pathRequired()
  31.     {
  32.         return new self('Specifying the paths to your entities is required ' .
  33.             'in the AnnotationDriver to retrieve all class names.');
  34.     }
  35.     /**
  36.      * @param class-string $driverClassName
  37.      */
  38.     public static function pathRequiredForDriver(string $driverClassName): self
  39.     {
  40.         return new self(sprintf(
  41.             'Specifying the paths to your entities is required when using %s to retrieve all class names.',
  42.             $driverClassName
  43.         ));
  44.     }
  45.     /**
  46.      * @param string|null $path
  47.      *
  48.      * @return self
  49.      */
  50.     public static function fileMappingDriversRequireConfiguredDirectoryPath($path null)
  51.     {
  52.         if (! empty($path)) {
  53.             $path '[' $path ']';
  54.         }
  55.         return new self(sprintf(
  56.             'File mapping drivers must have a valid directory path, ' .
  57.             'however the given path %s seems to be incorrect!',
  58.             (string) $path
  59.         ));
  60.     }
  61.     /**
  62.      * @param string $entityName
  63.      * @param string $fileName
  64.      *
  65.      * @return self
  66.      */
  67.     public static function mappingFileNotFound($entityName$fileName)
  68.     {
  69.         return new self(sprintf(
  70.             "No mapping file found named '%s' for class '%s'.",
  71.             $fileName,
  72.             $entityName
  73.         ));
  74.     }
  75.     /**
  76.      * @param string $entityName
  77.      * @param string $fileName
  78.      *
  79.      * @return self
  80.      */
  81.     public static function invalidMappingFile($entityName$fileName)
  82.     {
  83.         return new self(sprintf(
  84.             "Invalid mapping file '%s' for class '%s'.",
  85.             $fileName,
  86.             $entityName
  87.         ));
  88.     }
  89.     /**
  90.      * @param string $className
  91.      *
  92.      * @return self
  93.      */
  94.     public static function nonExistingClass($className)
  95.     {
  96.         return new self(sprintf("Class '%s' does not exist"$className));
  97.     }
  98.     /**
  99.      * @param class-string $className
  100.      */
  101.     public static function classIsAnonymous(string $className): self
  102.     {
  103.         return new self(sprintf('Class "%s" is anonymous'$className));
  104.     }
  105. }