PageRenderTime 37ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/zf2/vendor/Zend/Amf/Value/Messaging/AbstractMessage.php

http://github.com/eryx/php-framework-benchmark
PHP | 96 lines | 26 code | 9 blank | 61 comment | 0 complexity | 7feee86700b3d393fe2394760a2a7c67 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
  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_Amf
  17. * @subpackage Value
  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. */
  21. /**
  22. * @namespace
  23. */
  24. namespace Zend\Amf\Value\Messaging;
  25. /**
  26. * This is the default Implementation of Message, which provides
  27. * a convenient base for behavior and association of common endpoints
  28. *
  29. * @package Zend_Amf
  30. * @subpackage Value
  31. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class AbstractMessage
  35. {
  36. /**
  37. * @var string Client identifier
  38. */
  39. public $clientId;
  40. /**
  41. * @var string Destination
  42. */
  43. public $destination;
  44. /**
  45. * @var string Message identifier
  46. */
  47. public $messageId;
  48. /**
  49. * @var int Message timestamp
  50. */
  51. public $timestamp;
  52. /**
  53. * @var int Message TTL
  54. */
  55. public $timeToLive;
  56. /**
  57. * @var object Message headers
  58. */
  59. public $headers;
  60. /**
  61. * @var string Message body
  62. */
  63. public $body;
  64. /**
  65. * generate a unique id
  66. *
  67. * Format is: ########-####-####-####-############
  68. * Where # is an uppercase letter or number
  69. * example: 6D9DC7EC-A273-83A9-ABE3-00005FD752D6
  70. *
  71. * @return string
  72. */
  73. public function generateId()
  74. {
  75. return sprintf(
  76. '%08X-%04X-%04X-%02X%02X-%012X',
  77. mt_rand(),
  78. mt_rand(0, 65535),
  79. bindec(substr_replace(
  80. sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
  81. ),
  82. bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),
  83. mt_rand(0, 255),
  84. mt_rand()
  85. );
  86. }
  87. }