InvalidArgumentException.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.doctrine-project.org>.
  18. */
  19. namespace Doctrine\Common\Proxy\Exception;
  20. use Doctrine\Common\Persistence\Proxy;
  21. use InvalidArgumentException as BaseInvalidArgumentException;
  22. /**
  23. * Proxy Invalid Argument Exception.
  24. *
  25. * @link www.doctrine-project.org
  26. * @since 2.4
  27. * @author Marco Pivetta <ocramius@gmail.com>
  28. */
  29. class InvalidArgumentException extends BaseInvalidArgumentException implements ProxyException
  30. {
  31. /**
  32. * @return self
  33. */
  34. public static function proxyDirectoryRequired()
  35. {
  36. return new self('You must configure a proxy directory. See docs for details');
  37. }
  38. /**
  39. * @param string $className
  40. * @param string $proxyNamespace
  41. *
  42. * @return self
  43. */
  44. public static function notProxyClass($className, $proxyNamespace)
  45. {
  46. return new self(sprintf('The class "%s" is not part of the proxy namespace "%s"', $className, $proxyNamespace));
  47. }
  48. /**
  49. * @param string $name
  50. *
  51. * @return self
  52. */
  53. public static function invalidPlaceholder($name)
  54. {
  55. return new self(sprintf('Provided placeholder for "%s" must be either a string or a valid callable', $name));
  56. }
  57. /**
  58. * @return self
  59. */
  60. public static function proxyNamespaceRequired()
  61. {
  62. return new self('You must configure a proxy namespace');
  63. }
  64. /**
  65. * @return self
  66. */
  67. public static function unitializedProxyExpected(Proxy $proxy)
  68. {
  69. return new self(sprintf('Provided proxy of type "%s" must not be initialized.', get_class($proxy)));
  70. }
  71. /**
  72. * @param mixed $callback
  73. *
  74. * @return self
  75. */
  76. public static function invalidClassNotFoundCallback($callback)
  77. {
  78. $type = is_object($callback) ? get_class($callback) : gettype($callback);
  79. return new self(sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type));
  80. }
  81. }