PageRenderTime 62ms CodeModel.GetById 37ms RepoModel.GetById 1ms app.codeStats 0ms

/src/application/libraries/Zend/Service/DeveloperGarden/Credential.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 186 lines | 78 code | 17 blank | 91 comment | 10 complexity | 85107f3c9a235266ff05b4adffc64472 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: Credential.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @category Zend
  24. * @package Zend_Service
  25. * @subpackage DeveloperGarden
  26. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @author Marco Kaiser
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class Zend_Service_DeveloperGarden_Credential
  31. {
  32. /**
  33. * Service Auth Username
  34. *
  35. * @var string
  36. */
  37. protected $_username = null;
  38. /**
  39. * Service Password
  40. *
  41. * @var string
  42. */
  43. protected $_password = null;
  44. /**
  45. * Service Realm - default t-online.de
  46. *
  47. * @var string
  48. */
  49. protected $_realm = 't-online.de';
  50. /**
  51. * constructor to init the internal data
  52. *
  53. * @param string $username
  54. * @param string $password
  55. * @param string $realm
  56. * @return Zend_Service_DeveloperGarden_Credential
  57. */
  58. public function __construct($username = null, $password = null, $realm = null)
  59. {
  60. if (!empty($username)) {
  61. $this->setUsername($username);
  62. }
  63. if (!empty($password)) {
  64. $this->setPassword($password);
  65. }
  66. if (!empty($realm)) {
  67. $this->setRealm($realm);
  68. }
  69. }
  70. /**
  71. * split the password into an array
  72. *
  73. * @param string $password
  74. * @throws Zend_Service_DeveloperGarden_Client_Exception
  75. * @return Zend_Service_DeveloperGarden_Client_ClientAbstract
  76. */
  77. public function setPassword($password = null)
  78. {
  79. if (empty($password)) {
  80. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  81. throw new Zend_Service_DeveloperGarden_Client_Exception('Empty password not permitted.');
  82. }
  83. if (!is_string($password)) {
  84. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  85. throw new Zend_Service_DeveloperGarden_Client_Exception('Password must be a string.');
  86. }
  87. $this->_password = $password;
  88. return $this;
  89. }
  90. /**
  91. * returns the current configured password
  92. *
  93. * @return string
  94. */
  95. public function getPassword()
  96. {
  97. return $this->_password;
  98. }
  99. /**
  100. * set the new login
  101. *
  102. * @param string $username
  103. * @throws Zend_Service_DeveloperGarden_Client_Exception
  104. * @return Zend_Service_DeveloperGarden_Client_ClientAbstract
  105. */
  106. public function setUsername($username = null)
  107. {
  108. if (empty($username)) {
  109. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  110. throw new Zend_Service_DeveloperGarden_Client_Exception('Empty username not permitted.');
  111. }
  112. if (!is_string($username)) {
  113. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  114. throw new Zend_Service_DeveloperGarden_Client_Exception('Username must be a string.');
  115. }
  116. $this->_username = $username;
  117. return $this;
  118. }
  119. /**
  120. * returns the username
  121. *
  122. * if $withRealm == true we combine username and realm like
  123. * username@realm
  124. *
  125. * @param bool $withRealm
  126. * @return string|null
  127. */
  128. public function getUsername($withRealm = false)
  129. {
  130. $retValue = $this->_username;
  131. if ($withRealm) {
  132. $retValue = sprintf(
  133. '%s@%s',
  134. $this->_username,
  135. $this->_realm
  136. );
  137. }
  138. return $retValue;
  139. }
  140. /**
  141. * set the new realm
  142. *
  143. * @param string $realm
  144. * @throws Zend_Service_DeveloperGarden_Client_Exception
  145. * @return Zend_Service_DeveloperGarden_Client_ClientAbstract
  146. */
  147. public function setRealm($realm = null)
  148. {
  149. if (empty($realm)) {
  150. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  151. throw new Zend_Service_DeveloperGarden_Client_Exception('Empty realm not permitted.');
  152. }
  153. if (!is_string($realm)) {
  154. require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
  155. throw new Zend_Service_DeveloperGarden_Client_Exception('Realm must be a string.');
  156. }
  157. $this->_realm = $realm;
  158. return $this;
  159. }
  160. /**
  161. * returns the realm
  162. *
  163. * @return string|null
  164. */
  165. public function getRealm()
  166. {
  167. return $this->_realm;
  168. }
  169. }