PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Auth/Result.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 148 lines | 41 code | 17 blank | 90 comment | 1 complexity | ae99e12d4b9baeec6946c25f68762ef4 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_Auth
  17. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Result.php 23775 2011-03-01 17:25:24Z ralph $
  20. */
  21. /**
  22. * @category Zend
  23. * @package Zend_Auth
  24. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  25. * @license http://framework.zend.com/license/new-bsd New BSD License
  26. */
  27. class Zend_Auth_Result
  28. {
  29. /**
  30. * General Failure
  31. */
  32. const FAILURE = 0;
  33. /**
  34. * Failure due to identity not being found.
  35. */
  36. const FAILURE_IDENTITY_NOT_FOUND = -1;
  37. /**
  38. * Failure due to identity being ambiguous.
  39. */
  40. const FAILURE_IDENTITY_AMBIGUOUS = -2;
  41. /**
  42. * Failure due to invalid credential being supplied.
  43. */
  44. const FAILURE_CREDENTIAL_INVALID = -3;
  45. /**
  46. * Failure due to uncategorized reasons.
  47. */
  48. const FAILURE_UNCATEGORIZED = -4;
  49. /**
  50. * Authentication success.
  51. */
  52. const SUCCESS = 1;
  53. /**
  54. * Authentication result code
  55. *
  56. * @var int
  57. */
  58. protected $_code;
  59. /**
  60. * The identity used in the authentication attempt
  61. *
  62. * @var mixed
  63. */
  64. protected $_identity;
  65. /**
  66. * An array of string reasons why the authentication attempt was unsuccessful
  67. *
  68. * If authentication was successful, this should be an empty array.
  69. *
  70. * @var array
  71. */
  72. protected $_messages;
  73. /**
  74. * Sets the result code, identity, and failure messages
  75. *
  76. * @param int $code
  77. * @param mixed $identity
  78. * @param array $messages
  79. * @return void
  80. */
  81. public function __construct($code, $identity, array $messages = array())
  82. {
  83. $code = (int) $code;
  84. if ($code < self::FAILURE_UNCATEGORIZED) {
  85. $code = self::FAILURE;
  86. } elseif ($code > self::SUCCESS ) {
  87. $code = 1;
  88. }
  89. $this->_code = $code;
  90. $this->_identity = $identity;
  91. $this->_messages = $messages;
  92. }
  93. /**
  94. * Returns whether the result represents a successful authentication attempt
  95. *
  96. * @return boolean
  97. */
  98. public function isValid()
  99. {
  100. return ($this->_code > 0) ? true : false;
  101. }
  102. /**
  103. * getCode() - Get the result code for this authentication attempt
  104. *
  105. * @return int
  106. */
  107. public function getCode()
  108. {
  109. return $this->_code;
  110. }
  111. /**
  112. * Returns the identity used in the authentication attempt
  113. *
  114. * @return mixed
  115. */
  116. public function getIdentity()
  117. {
  118. return $this->_identity;
  119. }
  120. /**
  121. * Returns an array of string reasons why the authentication attempt was unsuccessful
  122. *
  123. * If authentication was successful, this method returns an empty array.
  124. *
  125. * @return array
  126. */
  127. public function getMessages()
  128. {
  129. return $this->_messages;
  130. }
  131. }