InvalidArgumentException.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace Doctrine\Common\Proxy\Exception;
  3. use Doctrine\Common\Persistence\Proxy;
  4. use InvalidArgumentException as BaseInvalidArgumentException;
  5. /**
  6. * Proxy Invalid Argument Exception.
  7. *
  8. * @link www.doctrine-project.org
  9. * @since 2.4
  10. * @author Marco Pivetta <ocramius@gmail.com>
  11. *
  12. * @deprecated The Doctrine\Common\Proxy component is deprecated, please use ocramius/proxy-manager instead.
  13. */
  14. class InvalidArgumentException extends BaseInvalidArgumentException implements ProxyException
  15. {
  16. /**
  17. * @return self
  18. */
  19. public static function proxyDirectoryRequired()
  20. {
  21. return new self('You must configure a proxy directory. See docs for details');
  22. }
  23. /**
  24. * @param string $className
  25. * @param string $proxyNamespace
  26. *
  27. * @return self
  28. */
  29. public static function notProxyClass($className, $proxyNamespace)
  30. {
  31. return new self(sprintf('The class "%s" is not part of the proxy namespace "%s"', $className, $proxyNamespace));
  32. }
  33. /**
  34. * @param string $name
  35. *
  36. * @return self
  37. */
  38. public static function invalidPlaceholder($name)
  39. {
  40. return new self(sprintf('Provided placeholder for "%s" must be either a string or a valid callable', $name));
  41. }
  42. /**
  43. * @return self
  44. */
  45. public static function proxyNamespaceRequired()
  46. {
  47. return new self('You must configure a proxy namespace');
  48. }
  49. /**
  50. * @param Proxy $proxy
  51. *
  52. * @return self
  53. */
  54. public static function unitializedProxyExpected(Proxy $proxy)
  55. {
  56. return new self(sprintf('Provided proxy of type "%s" must not be initialized.', get_class($proxy)));
  57. }
  58. /**
  59. * @param mixed $callback
  60. *
  61. * @return self
  62. */
  63. public static function invalidClassNotFoundCallback($callback)
  64. {
  65. $type = is_object($callback) ? get_class($callback) : gettype($callback);
  66. return new self(sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type));
  67. }
  68. /**
  69. * @param string $className
  70. *
  71. * @return self
  72. */
  73. public static function classMustNotBeAbstract($className)
  74. {
  75. return new self(sprintf('Unable to create a proxy for an abstract class "%s".', $className));
  76. }
  77. /**
  78. * @param string $className
  79. *
  80. * @return self
  81. */
  82. public static function classMustNotBeFinal($className)
  83. {
  84. return new self(sprintf('Unable to create a proxy for a final class "%s".', $className));
  85. }
  86. /**
  87. * @param mixed $value
  88. *
  89. * @return self
  90. */
  91. public static function invalidAutoGenerateMode($value) : self
  92. {
  93. return new self(sprintf('Invalid auto generate mode "%s" given.', $value));
  94. }
  95. }