Result.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ 3c/+9IIRYQ7YYZv1MCM4lI9HXr5ST+MpVhz6AyFk9zk=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.0
  11. */
  12. /**
  13. * authentication result class
  14. */
  15. namespace Cube\Authentication;
  16. class Result
  17. {
  18. /**
  19. *
  20. * authentication result
  21. *
  22. * @var bool
  23. */
  24. protected $_valid;
  25. /**
  26. *
  27. * identity used
  28. *
  29. * @var mixed
  30. */
  31. protected $_identity;
  32. /**
  33. *
  34. * messages to output
  35. *
  36. * @var array
  37. */
  38. protected $_messages = array();
  39. /**
  40. *
  41. * class constructor
  42. *
  43. * @param bool $valid
  44. * @param mixed $identity
  45. * @param array $messages
  46. */
  47. public function __construct($valid, $identity, $messages = array())
  48. {
  49. $this->setValid($valid);
  50. $this->setIdentity($identity);
  51. $this->setMessages($messages);
  52. }
  53. /**
  54. *
  55. * set valid flag
  56. *
  57. * @param bool $valid
  58. */
  59. public function setValid($valid)
  60. {
  61. $this->_valid = (bool) $valid;
  62. }
  63. /**
  64. *
  65. * get identity used
  66. *
  67. * @return mixed
  68. */
  69. public function getIdentity()
  70. {
  71. return $this->_identity;
  72. }
  73. /**
  74. *
  75. * set identity used
  76. *
  77. * @param mixed $identity
  78. */
  79. public function setIdentity($identity)
  80. {
  81. $this->_identity = $identity;
  82. }
  83. /**
  84. *
  85. * get authentication failure messages
  86. *
  87. * @return array
  88. */
  89. public function getMessages()
  90. {
  91. return $this->_messages;
  92. }
  93. /**
  94. *
  95. * set authentication failure messages
  96. *
  97. * @param mixed $messages
  98. */
  99. public function setMessages($messages)
  100. {
  101. $this->_messages = (array) $messages;
  102. }
  103. /**
  104. *
  105. * check whether the authentication attempt was valid or not
  106. *
  107. * @return bool
  108. */
  109. public function isValid()
  110. {
  111. return (bool) $this->_valid;
  112. }
  113. }