PageRenderTime 51ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Zend/Exception.php

https://bitbucket.org/seyar/ari100krat.local
PHP | 95 lines | 36 code | 5 blank | 54 comment | 6 complexity | 55ee8977abba3e9c8c56937432434c4c MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /**
  21. * @category Zend
  22. * @package Zend
  23. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  24. * @license http://framework.zend.com/license/new-bsd New BSD License
  25. */
  26. class Zend_Exception extends Exception
  27. {
  28. /**
  29. * @var null|Exception
  30. */
  31. private $_previous = null;
  32. /**
  33. * Construct the exception
  34. *
  35. * @param string $msg
  36. * @param int $code
  37. * @param Exception $previous
  38. * @return void
  39. */
  40. public function __construct($msg = '', $code = 0, Exception $previous = null)
  41. {
  42. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  43. parent::__construct($msg, (int) $code);
  44. $this->_previous = $previous;
  45. } else {
  46. parent::__construct($msg, (int) $code, $previous);
  47. }
  48. }
  49. /**
  50. * Overloading
  51. *
  52. * For PHP < 5.3.0, provides access to the getPrevious() method.
  53. *
  54. * @param string $method
  55. * @param array $args
  56. * @return mixed
  57. */
  58. public function __call($method, array $args)
  59. {
  60. if ('getprevious' == strtolower($method)) {
  61. return $this->_getPrevious();
  62. }
  63. return null;
  64. }
  65. /**
  66. * String representation of the exception
  67. *
  68. * @return string
  69. */
  70. public function __toString()
  71. {
  72. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  73. if (null !== ($e = $this->getPrevious())) {
  74. return $e->__toString()
  75. . "\n\nNext "
  76. . parent::__toString();
  77. }
  78. }
  79. return parent::__toString();
  80. }
  81. /**
  82. * Returns previous Exception
  83. *
  84. * @return Exception|null
  85. */
  86. protected function _getPrevious()
  87. {
  88. return $this->_previous;
  89. }
  90. }