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

/src/application/libraries/Zend/Oauth/Token/AuthorizedRequest.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 102 lines | 45 code | 6 blank | 51 comment | 7 complexity | 7991dc3e52c9f8f399643517c8d5ffc7 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_Oauth
  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: AuthorizedRequest.php 23775 2011-03-01 17:25:24Z ralph $
  20. */
  21. /** Zend_Oauth_Token */
  22. require_once 'Zend/Oauth/Token.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Oauth
  26. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Oauth_Token_AuthorizedRequest extends Zend_Oauth_Token
  30. {
  31. /**
  32. * @var array
  33. */
  34. protected $_data = array();
  35. /**
  36. * Constructor
  37. *
  38. * @param null|array $data
  39. * @param null|Zend_Oauth_Http_Utility $utility
  40. * @return void
  41. */
  42. public function __construct(array $data = null, Zend_Oauth_Http_Utility $utility = null)
  43. {
  44. if ($data !== null) {
  45. $this->_data = $data;
  46. $params = $this->_parseData();
  47. if (count($params) > 0) {
  48. $this->setParams($params);
  49. }
  50. }
  51. if ($utility !== null) {
  52. $this->_httpUtility = $utility;
  53. } else {
  54. $this->_httpUtility = new Zend_Oauth_Http_Utility;
  55. }
  56. }
  57. /**
  58. * Retrieve token data
  59. *
  60. * @return array
  61. */
  62. public function getData()
  63. {
  64. return $this->_data;
  65. }
  66. /**
  67. * Indicate if token is valid
  68. *
  69. * @return bool
  70. */
  71. public function isValid()
  72. {
  73. if (isset($this->_params[self::TOKEN_PARAM_KEY])
  74. && !empty($this->_params[self::TOKEN_PARAM_KEY])
  75. ) {
  76. return true;
  77. }
  78. return false;
  79. }
  80. /**
  81. * Parse string data into array
  82. *
  83. * @return array
  84. */
  85. protected function _parseData()
  86. {
  87. $params = array();
  88. if (empty($this->_data)) {
  89. return;
  90. }
  91. foreach ($this->_data as $key => $value) {
  92. $params[rawurldecode($key)] = rawurldecode($value);
  93. }
  94. return $params;
  95. }
  96. }