PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Service/DeveloperGarden/Response/BaseType.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 140 lines | 52 code | 11 blank | 77 comment | 9 complexity | 56416187cc0d0fa4b00f7cdc4fb9c1d0 MD5 | raw file
  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_Service
  17. * @subpackage DeveloperGarden
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: BaseType.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @see Zend_Service_DeveloperGarden_Response_ResponseAbstract
  24. */
  25. require_once 'Zend/Service/DeveloperGarden/Response/ResponseAbstract.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Service
  29. * @subpackage DeveloperGarden
  30. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @author Marco Kaiser
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Service_DeveloperGarden_Response_BaseType
  35. extends Zend_Service_DeveloperGarden_Response_ResponseAbstract
  36. {
  37. /**
  38. * the status code
  39. *
  40. * @var string
  41. */
  42. public $statusCode = null;
  43. /**
  44. * the status message
  45. *
  46. * @var string
  47. */
  48. public $statusMessage = null;
  49. /**
  50. * parse the result
  51. *
  52. * @throws Zend_Service_DeveloperGarden_Response_Exception
  53. * @return Zend_Service_DeveloperGarden_Response_ResponseAbstract
  54. */
  55. public function parse()
  56. {
  57. if ($this->hasError()) {
  58. throw new Zend_Service_DeveloperGarden_Response_Exception(
  59. $this->getStatusMessage(),
  60. $this->getStatusCode()
  61. );
  62. }
  63. return $this;
  64. }
  65. /**
  66. * returns the error code
  67. *
  68. * @return string|null
  69. */
  70. public function getStatusCode()
  71. {
  72. return $this->statusCode;
  73. }
  74. /**
  75. * returns the error message
  76. *
  77. * @return string
  78. */
  79. public function getStatusMessage()
  80. {
  81. return $this->statusMessage;
  82. }
  83. /**
  84. * returns true if the errorCode is not null and not 0000
  85. *
  86. * @return boolean
  87. */
  88. public function isValid()
  89. {
  90. return ($this->statusCode === null
  91. || $this->statusCode == '0000');
  92. }
  93. /**
  94. * returns true if we have a error situation
  95. *
  96. * @return boolean
  97. */
  98. public function hasError()
  99. {
  100. return ($this->statusCode !== null
  101. && $this->statusCode != '0000');
  102. }
  103. /**
  104. * returns the error code (statusCode)
  105. *
  106. * @return string|null
  107. */
  108. public function getErrorCode()
  109. {
  110. if (empty($this->errorCode)) {
  111. return $this->statusCode;
  112. } else {
  113. return $this->errorCode;
  114. }
  115. }
  116. /**
  117. * returns the error message
  118. *
  119. * @return string
  120. */
  121. public function getErrorMessage()
  122. {
  123. if (empty($this->errorMessage)) {
  124. return $this->statusMessage;
  125. } else {
  126. return $this->errorMessage;
  127. }
  128. }
  129. }