VeInteractive_VePlatform - Version 16.4.5.0

Version Notes

New features and bug fixes.

Download this release

Release Info

Developer VeInteractive
Extension VeInteractive_VePlatform
Version 16.4.5.0
Comparing to
See all releases


Code changes from version 16.3.5.0 to 16.4.5.0

Files changed (179) hide show
  1. app/code/community/VeInteractive/VePlatform/Block/ConfigFieldset.php +100 -94
  2. app/code/community/VeInteractive/VePlatform/Block/Template.php +25 -13
  3. app/code/community/VeInteractive/VePlatform/Block/Vemaster.php +66 -15
  4. app/code/community/VeInteractive/VePlatform/Block/Vepixel.php +19 -15
  5. app/code/community/VeInteractive/VePlatform/Block/Vetag.php +11 -8
  6. app/code/community/VeInteractive/VePlatform/Helper/Data.php +62 -47
  7. app/code/community/VeInteractive/VePlatform/Helper/ExceptionHandler.php +119 -0
  8. app/code/community/VeInteractive/VePlatform/Model/Data.php +516 -252
  9. app/code/community/VeInteractive/VePlatform/Observer/AdminUserLoadAfter.php +40 -18
  10. app/code/community/VeInteractive/VePlatform/Observer/Layout.php +31 -28
  11. app/code/community/VeInteractive/VePlatform/Observer/ThanksPage.php +8 -6
  12. app/code/community/VeInteractive/VePlatform/composer.json +14 -0
  13. app/code/community/VeInteractive/VePlatform/composer.lock +283 -0
  14. app/code/community/VeInteractive/VePlatform/controllers/Adminhtml/CustomController.php +93 -62
  15. app/code/community/VeInteractive/VePlatform/controllers/IndexController.php +43 -6
  16. app/code/community/VeInteractive/VePlatform/etc/config.xml +2 -2
  17. app/code/community/VeInteractive/VePlatform/templates/vemaster.phtml +181 -3
  18. app/code/community/VeInteractive/VePlatform/vendor/autoload.php +7 -0
  19. app/code/community/VeInteractive/VePlatform/vendor/composer/ClassLoader.php +415 -0
  20. app/code/community/VeInteractive/VePlatform/vendor/composer/LICENSE +21 -0
  21. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_classmap.php +9 -0
  22. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_files.php +12 -0
  23. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_namespaces.php +9 -0
  24. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_psr4.php +14 -0
  25. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_real.php +70 -0
  26. app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_static.php +63 -0
  27. app/code/community/VeInteractive/VePlatform/vendor/composer/installed.json +276 -0
  28. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/CHANGELOG.md +1222 -0
  29. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/LICENSE +19 -0
  30. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/README.md +90 -0
  31. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/UPGRADING.md +1203 -0
  32. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/composer.json +41 -0
  33. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Client.php +398 -0
  34. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/ClientInterface.php +84 -0
  35. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +265 -0
  36. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +84 -0
  37. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +90 -0
  38. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +72 -0
  39. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +404 -0
  40. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +7 -0
  41. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +7 -0
  42. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +37 -0
  43. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +4 -0
  44. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +188 -0
  45. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +27 -0
  46. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +7 -0
  47. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +4 -0
  48. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +4 -0
  49. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +534 -0
  50. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +27 -0
  51. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +45 -0
  52. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +197 -0
  53. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +92 -0
  54. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +176 -0
  55. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +55 -0
  56. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +463 -0
  57. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/HandlerStack.php +273 -0
  58. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +182 -0
  59. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Middleware.php +254 -0
  60. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Pool.php +123 -0
  61. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +112 -0
  62. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +231 -0
  63. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RequestOptions.php +244 -0
  64. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +111 -0
  65. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/TransferStats.php +126 -0
  66. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/UriTemplate.php +241 -0
  67. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/functions.php +330 -0
  68. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/functions_include.php +6 -0
  69. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/CHANGELOG.md +31 -0
  70. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/LICENSE +19 -0
  71. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/Makefile +13 -0
  72. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/README.md +501 -0
  73. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/composer.json +31 -0
  74. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/phpunit.xml.dist +17 -0
  75. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/AggregateException.php +16 -0
  76. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/CancellationException.php +9 -0
  77. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/EachPromise.php +229 -0
  78. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/FulfilledPromise.php +82 -0
  79. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/Promise.php +273 -0
  80. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/PromiseInterface.php +93 -0
  81. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/PromisorInterface.php +15 -0
  82. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/RejectedPromise.php +87 -0
  83. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/RejectionException.php +47 -0
  84. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/TaskQueue.php +80 -0
  85. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/functions.php +500 -0
  86. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/functions_include.php +6 -0
  87. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php +14 -0
  88. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/EachPromiseTest.php +336 -0
  89. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php +108 -0
  90. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php +50 -0
  91. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/PromiseTest.php +591 -0
  92. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php +143 -0
  93. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php +47 -0
  94. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/TaskQueueTest.php +31 -0
  95. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/Thennable.php +24 -0
  96. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/bootstrap.php +4 -0
  97. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/functionsTest.php +694 -0
  98. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/CHANGELOG.md +70 -0
  99. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/LICENSE +19 -0
  100. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/Makefile +29 -0
  101. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/README.md +569 -0
  102. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/composer.json +35 -0
  103. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/phpunit.xml.dist +17 -0
  104. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/AppendStream.php +233 -0
  105. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/BufferStream.php +137 -0
  106. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/CachingStream.php +138 -0
  107. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/DroppingStream.php +42 -0
  108. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/FnStream.php +149 -0
  109. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/InflateStream.php +52 -0
  110. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +39 -0
  111. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/LimitStream.php +155 -0
  112. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/MessageTrait.php +183 -0
  113. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/MultipartStream.php +153 -0
  114. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/NoSeekStream.php +22 -0
  115. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/PumpStream.php +165 -0
  116. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Request.php +142 -0
  117. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Response.php +131 -0
  118. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/ServerRequest.php +346 -0
  119. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Stream.php +245 -0
  120. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +149 -0
  121. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/StreamWrapper.php +121 -0
  122. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/UploadedFile.php +316 -0
  123. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Uri.php +602 -0
  124. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/functions.php +826 -0
  125. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/functions_include.php +6 -0
  126. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/AppendStreamTest.php +186 -0
  127. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php +63 -0
  128. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php +193 -0
  129. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php +26 -0
  130. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/FnStreamTest.php +90 -0
  131. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/FunctionsTest.php +619 -0
  132. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php +39 -0
  133. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php +64 -0
  134. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php +166 -0
  135. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php +242 -0
  136. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php +40 -0
  137. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php +72 -0
  138. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/RequestTest.php +195 -0
  139. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/ResponseTest.php +252 -0
  140. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php +532 -0
  141. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php +137 -0
  142. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamTest.php +161 -0
  143. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php +102 -0
  144. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php +280 -0
  145. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/UriTest.php +573 -0
  146. app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/bootstrap.php +11 -0
  147. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/Application.Insights.phpproj +72 -0
  148. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/Application.Insights.sln +22 -0
  149. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Application.php +46 -0
  150. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data.php +63 -0
  151. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data_Point.php +150 -0
  152. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data_Point_Type.php +10 -0
  153. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Device.php +267 -0
  154. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Envelope.php +287 -0
  155. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Event_Data.php +126 -0
  156. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Exception_Data.php +161 -0
  157. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Exception_Details.php +150 -0
  158. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Internal.php +63 -0
  159. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Location.php +46 -0
  160. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Message_Data.php +126 -0
  161. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Metric_Data.php +109 -0
  162. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Operation.php +97 -0
  163. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Page_View_Data.php +160 -0
  164. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Request_Data.php +249 -0
  165. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Session.php +80 -0
  166. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Stack_Frame.php +115 -0
  167. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/User.php +97 -0
  168. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Utils.php +112 -0
  169. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Telemetry_Channel.php +191 -0
  170. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Current_Session.php +49 -0
  171. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Current_User.php +34 -0
  172. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Telemetry_Client.php +285 -0
  173. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Telemetry_Context.php +228 -0
  174. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Bootstrap.php +3 -0
  175. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Channel/Contracts/Utils_Test.php +31 -0
  176. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Channel/Telemetry_Channel_Test.php +29 -0
  177. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Current_Session_Test.php +50 -0
  178. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Current_User_Test.php +43 -0
  179. app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Telemetry_Client_Test.php +210 -0
app/code/community/VeInteractive/VePlatform/Block/ConfigFieldset.php CHANGED
@@ -1,123 +1,129 @@
1
  <?php
2
 
3
  class VeInteractive_VePlatform_Block_ConfigFieldset
4
- extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
5
-
6
- const MY_SECTION = "veplatform_options";
7
- const MY_PACKAGE = "veplatform";
8
- const MY_THEME = "default";
9
- const PUBLIC_DESIGN_AREA = "skin";
10
- const IMAGES_DIR = "images";
11
- const FONTS_DIR = "fonts";
12
- const CSS_DIR = "css";
13
- const SCRIPTS_DIR = "scripts";
14
- const HEADER_TEMPLATE_PATH = "systemconfig/%s/formfieldset/header.phtml";
15
- const FOOTER_TEMPLATE_PATH = "systemconfig/%s/formfieldset/footer.phtml";
16
-
17
- private $on_my_section;
18
-
19
- public function getMyImagesUrl($image) {
20
- return $this->getSkinUrl() . self::IMAGES_DIR . DS . $image;
21
- }
22
-
23
- public function getMyFontsUrl($font) {
24
- return $this->getSkinUrl() . self::FONTS_DIR . DS . $font;
25
- }
26
-
27
- public function getMyCssUrl($css) {
28
- return $this->getSkinUrl() . self::CSS_DIR . DS . $css;
29
- }
30
-
31
- public function getMyScriptsUrl($script) {
32
- return $this->getSkinUrl() . self::SCRIPTS_DIR . DS . $script;
33
- }
34
 
35
- protected function _construct() {
36
- parent::_construct();
37
- $section = $this->getAction()->getRequest()->getParam('section', false);
38
- $this->on_my_section = ($section === self::MY_SECTION);
39
- }
40
 
41
- /* To use this function remove fieldset from template.
42
- protected function _getHeaderHtml( $element ) {
 
 
43
 
44
- $header = parent::_getHeaderHtml( $element );
 
 
 
45
 
46
- if( $this->on_my_section ) {
 
 
 
 
 
47
 
48
- $header_without_table = $this->removeTable( $header, true );
49
- if( $header_without_table !== false ) {
50
- $this->found_table = true;
51
- $this->setData( "parent_html_id", $element->getHtmlId() );
52
- $template_path = sprintf( self::HEADER_TEMPLATE_PATH, $element->getHtmlId() );
53
- $header = $header_without_table. $this->generateHtml( $template_path );
54
- }
55
 
56
- }
57
 
58
- return $header;
59
 
60
- }
61
- */
 
 
 
 
 
62
 
63
- protected function _getHeaderHtml($element) {
64
 
 
65
 
66
- if(!$this->on_my_section) {
67
- $header = parent::_getHeaderHtml($element);
68
- } else {
69
- $this->setData("parent_html_id", $element->getHtmlId());
70
- $template_path = sprintf(self::HEADER_TEMPLATE_PATH, $element->getHtmlId());
71
- $header = $this->generateHtml($template_path);
72
  }
73
- return $header;
74
- }
75
-
76
- /* To use this function remove fieldset from template.
77
- protected function _getFooterHtml( $element ) {
 
 
 
 
 
 
 
 
78
 
79
- $footer = parent::_getFooterHtml( $element );
 
80
 
81
- if( $this->on_my_section && $this->found_table ) {
82
 
83
- $footer_without_table = $this->removeTable( $footer, false );
84
- if( $footer_without_table !== false ) {
85
- $template_path = sprintf( self::FOOTER_TEMPLATE_PATH, $element->getHtmlId() );
86
- $footer = $footer_without_table. $this->generateHtml( $template_path );
87
- }
88
 
89
- }
 
 
 
 
90
 
91
- return $footer;
92
- }
93
- */
94
 
95
- protected function _getFooterHtml($element) {
96
- if(!$this->on_my_section) {
97
- $footer = parent::_getFooterHtml($element);
98
- } else {
99
- $template_path = sprintf(self::FOOTER_TEMPLATE_PATH, $element->getHtmlId());
100
- $footer = $this->generateHtml($template_path);
 
 
 
 
 
 
 
101
  }
102
- return $footer;
103
- }
104
-
105
- private function generateHtml($template_path) {
106
 
107
- $this->setTemplate($template_path);
 
 
108
 
109
- // Change Theme only for this Block.
110
- $design = Mage::getDesign();
111
- $package_name = $design->getPackageName();
112
- $theme_name = $design->getTheme(self::PUBLIC_DESIGN_AREA);
113
- $design->setPackageName(self::MY_PACKAGE)->setTheme(self::MY_THEME);
114
 
115
- $html = $this->toHtml();
116
 
117
- // Restore Theme.
118
- $design->setPackageName($package_name)->setTheme($theme_name);
119
 
120
- return $html;
121
 
122
- }
123
  }
1
  <?php
2
 
3
  class VeInteractive_VePlatform_Block_ConfigFieldset
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
5
+ {
6
+
7
+ const MY_SECTION = "veplatform_options";
8
+ const MY_PACKAGE = "veplatform";
9
+ const MY_THEME = "default";
10
+ const PUBLIC_DESIGN_AREA = "skin";
11
+ const IMAGES_DIR = "images";
12
+ const FONTS_DIR = "fonts";
13
+ const CSS_DIR = "css";
14
+ const SCRIPTS_DIR = "scripts";
15
+ const HEADER_TEMPLATE_PATH = "systemconfig/%s/formfieldset/header.phtml";
16
+ const FOOTER_TEMPLATE_PATH = "systemconfig/%s/formfieldset/footer.phtml";
17
+
18
+ private $on_my_section;
19
+
20
+ public function getMyImagesUrl($image)
21
+ {
22
+ return $this->getSkinUrl() . self::IMAGES_DIR . DS . $image;
23
+ }
 
 
 
 
 
 
 
 
 
 
24
 
25
+ public function getMyFontsUrl($font)
26
+ {
27
+ return $this->getSkinUrl() . self::FONTS_DIR . DS . $font;
28
+ }
 
29
 
30
+ public function getMyCssUrl($css)
31
+ {
32
+ return $this->getSkinUrl() . self::CSS_DIR . DS . $css;
33
+ }
34
 
35
+ public function getMyScriptsUrl($script)
36
+ {
37
+ return $this->getSkinUrl() . self::SCRIPTS_DIR . DS . $script;
38
+ }
39
 
40
+ protected function _construct()
41
+ {
42
+ parent::_construct();
43
+ $section = $this->getAction()->getRequest()->getParam('section', false);
44
+ $this->on_my_section = ($section === self::MY_SECTION);
45
+ }
46
 
47
+ /* To use this function remove fieldset from template.
48
+ protected function _getHeaderHtml( $element ) {
 
 
 
 
 
49
 
50
+ $header = parent::_getHeaderHtml( $element );
51
 
52
+ if( $this->on_my_section ) {
53
 
54
+ $header_without_table = $this->removeTable( $header, true );
55
+ if( $header_without_table !== false ) {
56
+ $this->found_table = true;
57
+ $this->setData( "parent_html_id", $element->getHtmlId() );
58
+ $template_path = sprintf( self::HEADER_TEMPLATE_PATH, $element->getHtmlId() );
59
+ $header = $header_without_table. $this->generateHtml( $template_path );
60
+ }
61
 
62
+ }
63
 
64
+ return $header;
65
 
 
 
 
 
 
 
66
  }
67
+ */
68
+
69
+ protected function _getHeaderHtml($element)
70
+ {
71
+ if (!$this->on_my_section) {
72
+ $header = parent::_getHeaderHtml($element);
73
+ } else {
74
+ $this->setData("parent_html_id", $element->getHtmlId());
75
+ $template_path = sprintf(self::HEADER_TEMPLATE_PATH, $element->getHtmlId());
76
+ $header = $this->generateHtml($template_path);
77
+ }
78
+ return $header;
79
+ }
80
 
81
+ /* To use this function remove fieldset from template.
82
+ protected function _getFooterHtml( $element ) {
83
 
84
+ $footer = parent::_getFooterHtml( $element );
85
 
86
+ if( $this->on_my_section && $this->found_table ) {
 
 
 
 
87
 
88
+ $footer_without_table = $this->removeTable( $footer, false );
89
+ if( $footer_without_table !== false ) {
90
+ $template_path = sprintf( self::FOOTER_TEMPLATE_PATH, $element->getHtmlId() );
91
+ $footer = $footer_without_table. $this->generateHtml( $template_path );
92
+ }
93
 
94
+ }
 
 
95
 
96
+ return $footer;
97
+ }
98
+ */
99
+
100
+ protected function _getFooterHtml($element)
101
+ {
102
+ if (!$this->on_my_section) {
103
+ $footer = parent::_getFooterHtml($element);
104
+ } else {
105
+ $template_path = sprintf(self::FOOTER_TEMPLATE_PATH, $element->getHtmlId());
106
+ $footer = $this->generateHtml($template_path);
107
+ }
108
+ return $footer;
109
  }
 
 
 
 
110
 
111
+ private function generateHtml($template_path)
112
+ {
113
+ $this->setTemplate($template_path);
114
 
115
+ // Change Theme only for this Block.
116
+ $design = Mage::getDesign();
117
+ $package_name = $design->getPackageName();
118
+ $theme_name = $design->getTheme(self::PUBLIC_DESIGN_AREA);
119
+ $design->setPackageName(self::MY_PACKAGE)->setTheme(self::MY_THEME);
120
 
121
+ $html = $this->toHtml();
122
 
123
+ // Restore Theme.
124
+ $design->setPackageName($package_name)->setTheme($theme_name);
125
 
126
+ return $html;
127
 
128
+ }
129
  }
app/code/community/VeInteractive/VePlatform/Block/Template.php CHANGED
@@ -1,19 +1,31 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Block_Template extends Mage_Core_Block_Template {
 
 
 
 
4
 
5
- public function __construct() {
6
- parent::__construct();
7
- }
 
 
8
 
9
- public function renderLocalTemplate($template_name, $params = array()) {
10
- $template_path = Mage::getModuleDir('', $this->getModuleName()) . DS . 'templates' . DS . $template_name . '.phtml';
11
-
12
- ob_start();
13
- require $template_path;
14
- $html = ob_get_contents();
15
- ob_end_clean();
16
 
17
- return $html;
18
- }
 
 
 
 
 
 
 
 
 
19
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Block_Template extends Mage_Core_Block_Template
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
 
9
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
10
+ if (file_exists($filePath)) {
11
+ require_once $filePath;
12
+ }
13
+ }
14
 
15
+ public function renderLocalTemplate($template_name, $params = array())
16
+ {
17
+ try {
18
+ $template_path = Mage::getModuleDir('', $this->getModuleName()) . DS . 'templates' . DS . $template_name . '.phtml';
 
 
 
19
 
20
+ ob_start();
21
+ require $template_path;
22
+ $html = ob_get_contents();
23
+ ob_end_clean();
24
+
25
+ return $html;
26
+ } catch(Exception $ex) {
27
+ $exceptionHandler = new ExceptionHandler();
28
+ $exceptionHandler->logException($ex);
29
+ }
30
+ }
31
  }
app/code/community/VeInteractive/VePlatform/Block/Vemaster.php CHANGED
@@ -1,33 +1,84 @@
1
  <?php
 
 
 
 
2
 
3
  class VeInteractive_VePlatform_Block_Vemaster extends VeInteractive_VePlatform_Block_Template
4
  {
5
-
6
- protected $data;
7
-
 
 
8
  public function __construct()
9
  {
10
  parent::__construct();
11
- $this->data = Mage::getModel('VeInteractive_VePlatform/data');
12
- }
13
 
14
- public function getMasterData(){
15
- $masterData = array(
16
- 'currency' => $this->data->getCurrency(),
17
- 'language' => $this->data->getLanguage(),
18
- 'culture' => $this->data->getCultureInformation(),
19
- 'user' => $this->data->getCustomer(),
20
- 'currentPage' => $this->data->getCurrentPage(),
21
- 'history' => $this->data->getUserHistory(),
22
- 'cart' => $this->data->getCurrentOrder()
 
 
 
 
 
 
 
 
 
 
 
 
23
  );
 
 
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  return $masterData;
27
  }
28
 
 
 
 
 
 
 
 
 
29
  public function _toHtml()
30
  {
31
- return $this->renderLocalTemplate( 'vemaster' );
32
  }
33
  }
1
  <?php
2
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
3
+ if (file_exists($filePath)) {
4
+ require_once $filePath;
5
+ }
6
 
7
  class VeInteractive_VePlatform_Block_Vemaster extends VeInteractive_VePlatform_Block_Template
8
  {
9
+
10
+ private $data;
11
+ private $exceptionHandler;
12
+
13
+
14
  public function __construct()
15
  {
16
  parent::__construct();
 
 
17
 
18
+ $this->data = Mage::getModel('VeInteractive_VePlatform_Model_Data',
19
+ array(
20
+ 'locale' => Mage::app()->getLocale(),
21
+ 'store' => Mage::app()->getStore(),
22
+ 'request' => Mage::app()->getRequest(),
23
+ 'coreSession' => Mage::getSingleton('core/session'),
24
+ 'catalogCategory' => Mage::getModel('catalog/category'),
25
+ 'catalogLayer' => Mage::getModel('catalog/layer'),
26
+ 'checkoutSession' => Mage::getModel('checkout/session'),
27
+ 'coreHelper' => Mage::helper('core'),
28
+ 'taxHelper' => Mage::helper('tax'),
29
+ 'currentProductRegistry' => Mage::registry('current_product'),
30
+ 'currentCategoryRegistry' => Mage::registry('current_category'),
31
+ 'customerSession' => Mage::getModel('customer/session'),
32
+ 'coreUrlHelper' => Mage::helper('core/url'),
33
+ 'checkoutHelper' => Mage::helper('checkout'),
34
+ 'directoryCurrency' => Mage::getModel('directory/currency'),
35
+ 'rule' => Mage::getModel('salesrule/rule'),
36
+ 'catalogMedia' => Mage::getModel('catalog/product_media_config'),
37
+ 'frontController' => Mage::app()->getFrontController()
38
+ )
39
  );
40
+ $this->exceptionHandler = new ExceptionHandler();
41
+ }
42
 
43
+ public function getMasterData()
44
+ {
45
+ try {
46
+ $masterData = array(
47
+ 'currency' => $this->data->getCurrency(),
48
+ 'language' => $this->data->getLanguage(),
49
+ 'culture' => $this->data->getCultureInformation(),
50
+ 'user' => $this->data->getCustomer(),
51
+ 'currentPage' => $this->data->getCurrentPage(),
52
+ 'history' => $this->data->getUserHistory(),
53
+ 'cart' => $this->data->getCurrentOrder()
54
+ );
55
+ } catch (Exception $ex) {
56
+ $this->exceptionHandler->logException($ex);
57
+
58
+ $masterData = array(
59
+ 'currency' => null,
60
+ 'language' => null,
61
+ 'culture' => null,
62
+ 'user' => null,
63
+ 'currentPage' => null,
64
+ 'history' => null,
65
+ 'cart' => null
66
+ );
67
+ }
68
 
69
  return $masterData;
70
  }
71
 
72
+ public function showVeData()
73
+ {
74
+ $isInstalled = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::MODULE_INSTALLED);
75
+ $isVeDataActive = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::VEDATAACTIVE) == "1";
76
+
77
+ return $isInstalled && $isVeDataActive;
78
+ }
79
+
80
  public function _toHtml()
81
  {
82
+ return $this->renderLocalTemplate('vemaster');
83
  }
84
  }
app/code/community/VeInteractive/VePlatform/Block/Vepixel.php CHANGED
@@ -1,23 +1,27 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Block_Vepixel extends VeInteractive_VePlatform_Block_Template {
 
4
 
5
- public function showPixel() {
6
- $show = Mage::getSingleton('core/session')->getShowPixel();
7
- if($show) {
8
- Mage::getSingleton('core/session')->unsShowPixel();
9
- }
 
10
 
11
- return $show;
12
- }
13
 
14
- public function journeyPixel() {
15
- $journeyPixel = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL);
 
16
 
17
- return $journeyPixel;
18
- }
19
 
20
- public function _toHtml() {
21
- return $this->renderLocalTemplate('vepixel');
22
- }
 
23
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Block_Vepixel extends VeInteractive_VePlatform_Block_Template
4
+ {
5
 
6
+ public function showPixel()
7
+ {
8
+ $show = Mage::getSingleton('core/session')->getShowPixel();
9
+ if ($show) {
10
+ Mage::getSingleton('core/session')->unsShowPixel();
11
+ }
12
 
13
+ return $show;
14
+ }
15
 
16
+ public function journeyPixel()
17
+ {
18
+ $journeyPixel = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL);
19
 
20
+ return $journeyPixel;
21
+ }
22
 
23
+ public function _toHtml()
24
+ {
25
+ return $this->renderLocalTemplate('vepixel');
26
+ }
27
  }
app/code/community/VeInteractive/VePlatform/Block/Vetag.php CHANGED
@@ -1,14 +1,17 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Block_Vetag extends VeInteractive_VePlatform_Block_Template {
 
4
 
5
- public function journeyTag() {
6
- $journeyTag = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::TAG_URL);
 
7
 
8
- return $journeyTag;
9
- }
10
 
11
- public function _toHtml() {
12
- return $this->renderLocalTemplate('vetag');
13
- }
 
14
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Block_Vetag extends VeInteractive_VePlatform_Block_Template
4
+ {
5
 
6
+ public function journeyTag()
7
+ {
8
+ $journeyTag = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::TAG_URL);
9
 
10
+ return $journeyTag;
11
+ }
12
 
13
+ public function _toHtml()
14
+ {
15
+ return $this->renderLocalTemplate('vetag');
16
+ }
17
  }
app/code/community/VeInteractive/VePlatform/Helper/Data.php CHANGED
@@ -1,65 +1,80 @@
1
  <?php
 
 
 
 
 
 
 
2
 
3
- class VeInteractive_VePlatform_Helper_Data extends Mage_Core_Helper_Abstract {
 
 
 
 
 
 
 
4
 
5
- const TAG_URL = 'veplatform/journey/tag';
6
- const PIXEL_URL = 'veplatform/journey/pixel';
7
- const TOKEN = 'veplatform/journey/token';
8
- const MODULE_INSTALLED = 'veplatform/adminhtml/module_installed';
9
- const FLOW_TYPE = 'veplatform/adminhtml/flow_type';
10
- const FIRST_INSTALL = 'veplatform/adminhtml/first_install';
11
- const ECOMMERCE_NAME = 'Magento';
12
 
13
- private $baseUrl;
 
 
 
 
14
 
15
- public function __construct() {
16
- $this->baseUrl = Mage::getConfig()->getNode('default/veplatform/service/url');
17
- }
18
 
19
- private function httpPost($url, $parameters) {
20
 
21
- Mage::log("BEGIN[httpPost] - Send(" . $url . ") = " . var_export($parameters, true), null, 'veplatform.log', true);
22
- $result = false;
23
- $response = false;
 
 
 
24
 
25
- $client = new Varien_Http_Client($url);
26
- $client->setMethod(Varien_Http_Client::POST);
27
- $client->setConfig(array(
28
- 'timeout' => 25,
29
- ));
30
 
31
- $client->setRawData(json_encode($parameters), "application/json;charset=UTF-8");
 
 
32
 
33
- try {
34
- $response = $client->request();
35
- $result = $response->getBody();
36
- Mage::log("END[httpPost] - Receive = Code" . var_export($result, true), null, 'veplatform.log', true);
37
 
38
- } catch (Exception $e) {
39
- Mage::log("END[httpPost] - Receive = " . $e->getMessage(), null, 'veplatform.log', true);
40
  }
41
 
42
- return $result;
43
- }
44
-
45
- public function install($data) {
46
- return $this->httpPost($this->baseUrl . '/api/veconnect/install', $data);
47
- }
48
 
49
- public function getLang() {
50
- $lang = Mage::getStoreConfig('general/locale/code');
51
- $subDashPositionInLang = strpos($lang, '_');
52
- if($subDashPositionInLang > 0) {
53
- $lang = substr($lang, 0, $subDashPositionInLang);
 
 
 
 
 
54
  }
55
- return $lang;
56
- }
57
 
58
- public function getBaseUrl() {
59
- return preg_replace("(^https?://)", "", Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false));
60
- }
 
61
 
62
- public function getPlatformName() {
63
- return self::ECOMMERCE_NAME;
64
- }
 
65
  }
1
  <?php
2
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
3
+ if (file_exists($filePath)) {
4
+ require_once $filePath;
5
+ }
6
+
7
+ class VeInteractive_VePlatform_Helper_Data extends Mage_Core_Helper_Abstract
8
+ {
9
 
10
+ const TAG_URL = 'veplatform/journey/tag';
11
+ const PIXEL_URL = 'veplatform/journey/pixel';
12
+ const TOKEN = 'veplatform/journey/token';
13
+ const MODULE_INSTALLED = 'veplatform/adminhtml/module_installed';
14
+ const FLOW_TYPE = 'veplatform/adminhtml/flow_type';
15
+ const FIRST_INSTALL = 'veplatform/adminhtml/first_install';
16
+ const ECOMMERCE_NAME = 'Magento';
17
+ const VEDATAACTIVE = 'veplatform/journey/vedataactive';
18
 
19
+ private $baseUrl;
20
+ private $exceptionHandler;
 
 
 
 
 
21
 
22
+ public function __construct()
23
+ {
24
+ $this->baseUrl = Mage::getConfig()->getNode('default/veplatform/service/url');
25
+ $this->exceptionHandler = new ExceptionHandler();
26
+ }
27
 
28
+ private function httpPost($url, $parameters)
29
+ {
30
+ $this->exceptionHandler->logMessage("BEGIN[httpPost] - Send(" . $url . ") = " . var_export($parameters, true), 'INFO');
31
 
32
+ $result = false;
33
 
34
+ try {
35
+ $client = new Varien_Http_Client($url);
36
+ $client->setMethod(Varien_Http_Client::POST);
37
+ $client->setConfig(array(
38
+ 'timeout' => 25,
39
+ ));
40
 
41
+ $client->setRawData(json_encode($parameters), "application/json;charset=UTF-8");
 
 
 
 
42
 
43
+ $response = $client->request();
44
+ $result = $response->getBody();
45
+ $this->exceptionHandler->logMessage("END[httpPost] - Receive = Code" . var_export($result, true), 'INFO');
46
 
47
+ } catch (Exception $exception) {
48
+ $this->exceptionHandler->logException($exception);
49
+ }
 
50
 
51
+ return $result;
 
52
  }
53
 
54
+ public function install($data)
55
+ {
56
+ return $this->httpPost($this->baseUrl . '/api/veconnect/install', $data);
57
+ }
 
 
58
 
59
+ public function getLang()
60
+ {
61
+ $lang = Mage::getStoreConfig('general/locale/code');
62
+ if(isset($lang)) {
63
+ $subDashPositionInLang = strpos($lang, '_');
64
+ if ($subDashPositionInLang > 0) {
65
+ $lang = substr($lang, 0, $subDashPositionInLang);
66
+ }
67
+ }
68
+ return $lang;
69
  }
 
 
70
 
71
+ public function getBaseUrl()
72
+ {
73
+ return preg_replace("(^https?://)", "", Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false));
74
+ }
75
 
76
+ public function getPlatformName()
77
+ {
78
+ return self::ECOMMERCE_NAME;
79
+ }
80
  }
app/code/community/VeInteractive/VePlatform/Helper/ExceptionHandler.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the GNU General Public License (GPL) version 3
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.gnu.org/licenses/
10
+ *
11
+ * @author Ve Interactive <info@veinteractive.com>
12
+ * @copyright 2016 Ve Interactive
13
+ * @license http://www.gnu.org/licenses/ GNU General Public License (GPL) version 3
14
+ */
15
+ class ExceptionHandler
16
+ {
17
+ public $error = array();
18
+ public $level = 'ERROR';
19
+
20
+ private $telemetryClient;
21
+ private $eCommerceName = 'Magento';
22
+ private $moduleVersion = '16.3.5.0';
23
+ private $phpVersion;
24
+ private $eCommerceVersion;
25
+ private $file = 'veplatform.log';
26
+
27
+ public function __construct()
28
+ {
29
+ $filePath = dirname(dirname(__FILE__)) . '/vendor/autoload.php';
30
+ if (file_exists($filePath)) {
31
+ require_once $filePath;
32
+ }
33
+
34
+ try {
35
+ $this->phpVersion = phpversion();
36
+ $this->eCommerceVersion = Mage::getVersion();
37
+ if ($this->validate()) {
38
+ $filePath = dirname(dirname(__FILE__)) . '/vendor/autoload.php';
39
+ if (file_exists($filePath) && class_exists('\ApplicationInsights\Telemetry_Client')) {
40
+ require_once $filePath;
41
+
42
+ $this->telemetryClient = new \ApplicationInsights\Telemetry_Client();
43
+ $this->telemetryClient->getContext()->setInstrumentationKey('7bab193b-a2ac-42a5-a07e-84943b8d2279');
44
+ } else {
45
+ $this->error['error'] = 'Ve module could not be installed - Composer files could not be loaded';
46
+ Mage::log($this->error['error'], $this->level, $this->file);
47
+ }
48
+ } else {
49
+ Mage::log($this->error['error'], $this->level, $this->file);
50
+ }
51
+ } catch (Exception $exception) {
52
+ Mage::log($exception, $this->level, $this->file);
53
+ }
54
+ }
55
+
56
+ public function validate()
57
+ {
58
+ if (version_compare($this->phpVersion, '5.5.0', '<=')) {
59
+ $this->error['error'] = 'Ve module could not be installed - PHP version needs to be at least 5.5';
60
+ } else if (!$this->checkCurlExtension() || !$this->checkGdExtension()) {
61
+ $this->error['error'] = 'Ve module could not be installed - CURL or Gd extensions are missing';
62
+ }
63
+
64
+ return empty($this->error);
65
+ }
66
+
67
+ public function checkCurlExtension()
68
+ {
69
+ return extension_loaded('curl') && function_exists('curl_init') && function_exists('curl_reset');
70
+ }
71
+
72
+ public function checkGdExtension()
73
+ {
74
+ return extension_loaded('gd') && function_exists('gd_info');
75
+ }
76
+
77
+ private function getContainerInfo($level)
78
+ {
79
+ return array(
80
+ 'Level' => $level,
81
+ 'Shop' => $this->eCommerceName,
82
+ 'Version' => $this->eCommerceVersion,
83
+ 'URL' => $this->getCurrentUrl(),
84
+ 'PHPVersion' => $this->phpVersion,
85
+ 'ModuleVersion' => $this->moduleVersion
86
+ );
87
+ }
88
+
89
+ public function logMessage($message, $level = 'INFO')
90
+ {
91
+ try {
92
+ if (isset($this->telemetryClient) && isset($message)) {
93
+ $this->telemetryClient->trackMessage($message, $this->getContainerInfo($level));
94
+ $this->telemetryClient->flush();
95
+ }
96
+ } catch (Exception $ex) {
97
+ Mage::log($message, $level, $this->file);
98
+ }
99
+
100
+ }
101
+
102
+ public function logException(\Exception $exception, $level = 'ERROR')
103
+ {
104
+ try {
105
+ if (isset($this->telemetryClient) && isset($exception)) {
106
+ $this->telemetryClient->trackException($exception, $this->getContainerInfo($level));
107
+ $this->telemetryClient->flush();
108
+ }
109
+ } catch (Exception $exception) {
110
+ Mage::log($exception, $level, $this->file);
111
+ }
112
+ }
113
+
114
+ private function getCurrentUrl()
115
+ {
116
+ $url = Mage::helper('core/url')->getCurrentUrl();
117
+ return $url;
118
+ }
119
+ }
app/code/community/VeInteractive/VePlatform/Model/Data.php CHANGED
@@ -4,14 +4,73 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
4
  {
5
 
6
  private $locale;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  /**
9
  * Get information related to date format for masterdata
10
  */
11
  public function getCultureInformation()
12
  {
13
- $dateFormat = $this->locale->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
14
- return array('dateFormatFull' => $dateFormat);
 
 
 
 
 
 
 
 
 
15
  }
16
 
17
  /**
@@ -19,18 +78,23 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
19
  */
20
  public function getLanguage()
21
  {
22
- if (empty($this->locale)) {
23
- $this->locale = Mage::app()->getLocale();
24
- }
25
-
26
- $languageCode = $this->locale->getLocaleCode();
27
 
28
- $language = array(
29
- 'isoCode' => null,
30
- 'languageCode' => $languageCode,
31
- 'name' => $this->getLanguageName($languageCode)
32
- );
 
 
33
 
 
 
 
 
 
 
34
  return $language;
35
  }
36
 
@@ -43,14 +107,18 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
43
  return null;
44
  }
45
 
46
- $optionLocales = $this->locale->getOptionLocales();
47
- foreach ($optionLocales as $oL) {
48
- if (strtolower($oL['value']) == strtolower($code)) {
49
- return $oL['label'];
 
 
50
  }
 
 
 
51
  }
52
 
53
- return null;
54
  }
55
 
56
  /**
@@ -58,17 +126,27 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
58
  */
59
  public function getCurrency()
60
  {
61
- $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
62
- $currencyObj = Mage::app()->getLocale()->currency($currency_code);
63
-
64
- $currency = array(
65
- 'isoCode' => $currency_code,
66
- 'isoCodeNum' => null,
67
- 'name' => $currencyObj->getName(),
68
- 'sign' => $currencyObj->getSymbol()
69
- );
70
- return $currency;
 
71
 
 
 
 
 
 
 
 
 
 
72
  }
73
 
74
  /**
@@ -77,53 +155,65 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
77
  */
78
  public function getCurrentPage()
79
  {
80
- $orderId = Mage::app()->getFrontController()->getRequest()->getActionName() === 'success' ? Mage::getModel('checkout/session')->getData('last_real_order_id') : 0;
81
- $module = Mage::app()->getFrontController()->getRequest()->getModuleName();
82
- $productId = 0;
83
-
84
- //Product page
85
- if ($module === 'catalog' && Mage::registry('current_product')) {
86
- $productId = Mage::registry('current_product')->getId();
87
- $latestViewedProducts = Mage::getSingleton('core/session')->getUserViewedProducts();
88
- if (!empty($latestViewedProducts)) {
89
- $latestViewedProducts .= ',' . $productId;
90
- Mage::getSingleton('core/session')->setUserViewedProducts($latestViewedProducts);
91
- } else {
92
- Mage::getSingleton('core/session')->setUserViewedProducts($productId);
 
 
 
 
93
  }
94
- Mage::getSingleton('core/session')->setHistory(true);
95
- }
96
 
97
- // Category page
98
- if ($module === 'catalog' && Mage::registry('current_category')) {
99
- // check if the category is a root category to avoid it
100
- if (Mage::getModel('catalog/layer')->getCurrentCategory()->getLevel() !== "1") {
101
-
102
- $catName = Mage::getSingleton('core/session')->getLastVisitedCategoryName();
103
- $catLink = Mage::getSingleton('core/session')->getLastVisitedCategoryLink();
104
-
105
- $currentCategoryName = Mage::getModel('catalog/layer')->getCurrentCategory()->getName();
106
- $currentCategoryLink = Mage::getModel('catalog/layer')->getCurrentCategory()->getUrl();
107
-
108
- if(!empty($catName) && !empty($catLink)) {
109
- $catName .= ',' . $currentCategoryName;
110
- $catLink .= ',' . $currentCategoryLink;
111
- Mage::getSingleton('core/session')->setLastVisitedCategoryName($catName);
112
- Mage::getSingleton('core/session')->setLastVisitedCategoryLink($catLink);
113
- }else{
114
- Mage::getSingleton('core/session')->setLastVisitedCategoryName($currentCategoryName);
115
- Mage::getSingleton('core/session')->setLastVisitedCategoryLink($currentCategoryLink);
 
 
116
  }
117
- Mage::getSingleton('core/session')->setHistory(true);
118
  }
119
- }
120
 
121
- $current = array(
122
- 'currentUrl' => Mage::helper('core/url')->getCurrentUrl(),
123
- 'orderId' => $orderId,
124
- 'currentPageType' => $this->getPageType(),
125
- 'product' => $this->getProductInformation($productId)
126
- );
 
 
 
 
 
 
 
 
 
 
127
 
128
  return $current;
129
  }
@@ -133,165 +223,224 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
133
  */
134
  public function getPageType()
135
  {
136
- $controller = Mage::app()->getRequest()->getControllerName();
137
- $action = Mage::app()->getRequest()->getActionName();
138
-
139
  $type = null;
140
- switch ($controller) {
141
- case 'index':
142
- $type = 'home';
143
- break;
144
- case 'account':
145
- if ($action == 'login') {
146
- $type = 'login';
147
- } else if ($action == 'create') {
148
- $type = 'register';
149
- }
150
- break;
151
- case 'product':
152
- $type = 'product';
153
- break;
154
- case 'cart':
155
- $type = 'basket';
156
- break;
157
- case 'category':
158
- $type = 'category';
159
- break;
160
- case 'onepage':
161
- if ($action != 'success') {
162
- $type = 'checkout';
163
- } else {
164
- $type = 'complete';
165
- }
166
- break;
167
- case 'multishipping':
168
- if ($action != 'success') {
169
- $type = 'checkout';
170
- } else {
171
- $type = 'complete';
172
- }
173
- break;
174
- default:
175
- $type = 'other';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
 
178
  return $type;
179
  }
180
 
181
  /**
182
- * Get current order, all cart information
183
  */
184
- public function getCurrentOrder()
185
  {
186
- $taxes = array(
187
- 'name' => null,
188
- 'taxValue' => null
189
- );
190
-
191
- $promocode = array(
192
- 'name' => null,
193
- 'type' => null,
194
- 'value' => null
195
- );
196
-
197
- $cart = array(
198
  'dateUpd' => null,
199
- 'promocode' => $promocode,
200
- 'totalPromocodeDiscount' => Mage::helper('core')->currency(0, true, false),
201
- 'totalPrice' => Mage::helper('core')->currency(0, true, false),
202
- 'totalProducts' => Mage::helper('core')->currency(0, true, false),
203
- 'products' => array(),
204
- 'taxes' => $taxes
205
  );
 
206
 
207
- $order = Mage::getModel('checkout/session')->getQuote();
208
- if ($order !== null) {
209
- $dateUpd = $order->getUpdatedAt();
210
- if ($order->hasItems()) {
211
- $products = array();
212
- $i = 0;
213
- foreach ($order->getAllVisibleItems() as $item) {
214
- $products[$i] = $this->getProductInformation($item->getProductId());
215
- $products[$i]['qty'] = $item->getQty();
216
- $i++;
217
- }
218
-
219
- $grandTotal = $order->getGrandTotal();
220
- $subtotal = $order->getSubtotal();
221
 
222
- if ($order->isVirtual()) {
223
- $totalTax = array(
224
- 'name' => 'Total Tax',
225
- 'taxValue' => Mage::helper('core')->currency($order->getBillingAddress()->getData('tax_amount'), true, false)
226
- );
227
- $discountAmount = $order->getBillingAddress()->getData('discount_amount');
228
- } else {
229
- $totalTax = array(
230
- 'name' => 'Total Tax',
231
- 'taxValue' => Mage::helper('core')->currency($order->getShippingAddress()->getData('tax_amount'), true, false)
232
- );
233
- $discountAmount = $order->getShippingAddress()->getData('discount_amount');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  }
235
 
236
- $tax[] = $totalTax;
 
 
 
 
 
 
237
  }
238
-
239
- $cart['dateUpd'] = $dateUpd;
240
- $cart['totalPrice'] = Mage::helper('core')->currency($grandTotal, true, false);
241
- $cart['totalProducts'] = Mage::helper('core')->currency($subtotal, true, false);
242
- $cart['products'] = $products;
243
- $cart['taxes'] = $tax;
244
- $cart['promocode'] = $this->getPromocode($order);
245
- $cart['totalPromocodeDiscount'] = Mage::helper('core')->currency(abs($discountAmount), true, false);
246
  }
247
 
248
  return $cart;
249
  }
250
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
  /**
253
  * Get promocodes applied for the current order
254
  */
255
  public function getPromocode($order)
256
  {
257
- $promocode = array();
258
-
259
- $ruleIds = explode(',', $order->getAppliedRuleIds());
260
- $ruleIds = array_unique($ruleIds);
261
 
262
- foreach ($ruleIds as $ruleId) {
263
- $rule = Mage::getModel('salesrule/rule');
264
- $rule->load($ruleId);
265
- if ($rule->getId()) {
266
- $type = $rule->getData('simple_action');
267
 
268
- $currentPromocode = array(
269
- 'name' => $rule->getData('name'),
270
- 'type' => $type,
271
- 'value' => $rule->getData('discount_amount')
272
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- $promocode[] = $currentPromocode;
 
 
275
  }
 
 
276
  }
277
 
278
- return !empty($promocode) ? $promocode :
279
- array(
280
- 'name' => null,
281
- 'type' => null,
282
- 'value' => null
283
- );
284
  }
285
 
286
  /**
287
- * Build product structure used used in currentPage and cart
288
  */
289
- public function getProductInformation($id)
290
  {
291
- $prod = array(
292
  'productId' => null,
293
  'description' => null,
294
- 'description_short' => null,
295
  'images' => array(
296
  'fullImagePath' => null,
297
  'partialImagePath' => null,
@@ -301,83 +450,192 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
301
  'priceCurrent' => null,
302
  'priceDiscount' => null,
303
  'priceWithoutDiscount' => null,
304
- 'productLink' => null
 
305
  );
 
306
 
307
- if (empty($id)) {
308
- return $prod;
309
- }
310
-
311
- $product = Mage::getModel('catalog/product');
312
- $product->load((int)$id);
 
 
 
 
313
 
314
- $imgFullPath = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
315
- $imgPartialPath = Mage::getModel('catalog/product_media_config')->getMediaShortUrl($product->getImage());
 
 
 
 
 
 
 
316
 
317
- $finalPrice = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
318
- $originalPrice = Mage::helper('tax')->getPrice($product, $product->getPrice(), true);
319
- $prod = array(
320
- 'productId' => $id,
321
- 'description' => $product->getData('description'),
322
- 'description_short' => $product->getData('short_description'),
323
- 'images' => array(
324
- 'fullImagePath' => $imgFullPath,
325
- 'partialImagePath' => $imgPartialPath,
326
- ),
327
- 'manufacturerName' => null,
328
- 'name' => $product->getName(),
329
- 'priceCurrent' => Mage::helper('core')->currency($finalPrice, true, false),
330
- 'priceDiscount' => Mage::helper('core')->currency(($originalPrice - $finalPrice), true, false),
331
- 'priceWithoutDiscount' => Mage::helper('core')->currency($originalPrice, true, false),
332
- 'productLink' => $product->getProductUrl(true)
333
- );
 
 
 
 
 
 
 
 
334
 
335
  return $prod;
336
  }
337
 
338
  /**
339
- * Get user history - products history and last visited category
 
 
 
340
  */
341
- public function getUserHistory()
342
- { $history = array();
343
- $hasHistory = Mage::getSingleton('core/session')->getHistory();
344
- if (!$hasHistory) {
345
- $history['productHistory'] = array();
346
- $history['lastVisitedCategory'] = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  'name' => null,
348
  'link' => null
349
  );
350
- } else {
351
- $latestViewedProducts = Mage::getSingleton('core/session')->getUserViewedProducts();
 
 
352
 
353
- $categoryName = Mage::getSingleton('core/session')->getLastVisitedCategoryName();
354
- $categoryLink = Mage::getSingleton('core/session')->getLastVisitedCategoryLink();
355
- if (!empty($latestViewedProducts)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  $productHistory = array();
357
- $productList = array_unique(explode(',', $latestViewedProducts));
358
- foreach ($productList as $productId) {
359
- $productHistory[] = $this->getProductInformation($productId);
 
 
360
  }
 
361
  $history['productHistory'] = $productHistory;
 
362
  }
363
- if (!empty($categoryName) && !empty($categoryLink)) {
364
- $catNameList = explode(',', $categoryName);
365
- $catLinkList = explode(',', $categoryLink);
366
-
367
- if(sizeof($catNameList) > 1) {
368
- $length = sizeof($catNameList);
369
- $history['lastVisitedCategory'] = array(
370
- 'name' => $catNameList[$length-2],
371
- 'link' => $catLinkList[$length-2]
372
- );
373
- }
374
- }else{
375
- $history['lastVisitedCategory'] = array(
376
  'name' => null,
377
  'link' => null
378
- );
379
- }
380
  }
 
381
  return $history;
382
  }
383
 
@@ -392,16 +650,22 @@ class VeInteractive_VePlatform_Model_Data extends Mage_Core_Model_Abstract
392
  'lastName' => null
393
  );
394
 
395
- $customer = Mage::getModel('customer/session');
396
- if ($customer->isLoggedIn()) {
397
- $customer = $customer->getCustomer();
398
- $customerInfo = array(
399
- 'email' => $customer->getEmail(),
400
- 'firstName' => $customer->getFirstname() . (!empty($customer->getMiddlename()) ? ' ' . $customer->getMiddlename() : ''),
401
- 'lastName' => $customer->getLastname()
402
- );
 
 
 
 
403
  }
404
 
405
  return $customerInfo;
406
  }
 
407
  }
 
4
  {
5
 
6
  private $locale;
7
+ private $store;
8
+ private $request;
9
+ private $coreSession;
10
+ private $catalogCategory;
11
+ private $catalogLayer;
12
+ private $checkoutSession;
13
+ private $coreHelper;
14
+ private $taxHelper;
15
+ private $currentProductRegistry;
16
+ private $currentCategoryRegistry;
17
+ private $customerSession;
18
+ private $coreUrlHelper;
19
+ private $checkoutHelper;
20
+ private $directoryCurrency;
21
+ private $rule;
22
+ private $catalogMedia;
23
+ private $frontController;
24
+
25
+ private $exceptionHandler;
26
+ private $storeDateTimeFormat;
27
+
28
+ public function __construct($parameters)
29
+ {
30
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
31
+ if (file_exists($filePath)) {
32
+ require_once $filePath;
33
+ }
34
+
35
+ $this->locale = $parameters['locale'];
36
+ $this->store = $parameters['store'];
37
+ $this->request = $parameters['request'];
38
+ $this->coreSession = $parameters['coreSession'];
39
+ $this->catalogCategory = $parameters['catalogCategory'];
40
+ $this->catalogLayer = $parameters['catalogLayer'];
41
+ $this->checkoutSession = $parameters['checkoutSession'];
42
+ $this->coreHelper = $parameters['coreHelper'];
43
+ $this->taxHelper = $parameters['taxHelper'];
44
+ $this->currentProductRegistry = $parameters['currentProductRegistry'];
45
+ $this->currentCategoryRegistry = $parameters['currentCategoryRegistry'];
46
+ $this->customerSession = $parameters['customerSession'];
47
+ $this->coreUrlHelper = $parameters['coreUrlHelper'];
48
+ $this->checkoutHelper = $parameters['checkoutHelper'];
49
+ $this->directoryCurrency = $parameters['directoryCurrency'];
50
+ $this->rule = $parameters['rule'];
51
+ $this->catalogMedia = $parameters['catalogMedia'];
52
+ $this->frontController = $parameters['frontController'];
53
+ $this->exceptionHandler = new ExceptionHandler();
54
+ $this->storeDateTimeFormat = Mage_Core_Model_Locale::FORMAT_TYPE_LONG;
55
+
56
+ }
57
 
58
  /**
59
  * Get information related to date format for masterdata
60
  */
61
  public function getCultureInformation()
62
  {
63
+ try {
64
+ $dateFormat = $this->locale->getDateTimeFormat($this->storeDateTimeFormat);
65
+ $cultureInfo = array('dateFormatFull' => $dateFormat);
66
+
67
+ return $cultureInfo;
68
+ } catch (Exception $exception) {
69
+ $this->exceptionHandler->logException($exception);
70
+
71
+ $cultureInfo = array('dateFormatFull' => null);
72
+ }
73
+ return $cultureInfo;
74
  }
75
 
76
  /**
78
  */
79
  public function getLanguage()
80
  {
81
+ try {
82
+ $languageCode = $this->locale->getLocaleCode();
 
 
 
83
 
84
+ $language = array(
85
+ 'isoCode' => null,
86
+ 'languageCode' => $languageCode,
87
+ 'name' => $this->getLanguageName($languageCode)
88
+ );
89
+ } catch (Exception $exception) {
90
+ $this->exceptionHandler->logException($exception);
91
 
92
+ $language = array(
93
+ 'isoCode' => null,
94
+ 'languageCode' => null,
95
+ 'name' => null
96
+ );
97
+ }
98
  return $language;
99
  }
100
 
107
  return null;
108
  }
109
 
110
+ try {
111
+ $optionLocales = $this->locale->getOptionLocales();
112
+ foreach ($optionLocales as $oL) {
113
+ if (strtolower($oL['value']) == strtolower($code)) {
114
+ return $oL['label'];
115
+ }
116
  }
117
+ } catch (Exception $exception) {
118
+ $this->exceptionHandler->logException($exception);
119
+ return null;
120
  }
121
 
 
122
  }
123
 
124
  /**
126
  */
127
  public function getCurrency()
128
  {
129
+ try {
130
+ $currencyCode = $this->store->getCurrentCurrencyCode();
131
+ $currencyObj = $this->locale->currency($currencyCode);
132
+ $currency = array(
133
+ 'isoCode' => $currencyCode,
134
+ 'isoCodeNum' => null,
135
+ 'name' => $currencyObj->getName(),
136
+ 'sign' => $currencyObj->getSymbol()
137
+ );
138
+ } catch (Exception $exception) {
139
+ $this->exceptionHandler->logException($exception);
140
 
141
+ $currency = array(
142
+ 'isoCode' => null,
143
+ 'isoCodeNum' => null,
144
+ 'name' => null,
145
+ 'sign' => null
146
+ );
147
+ }
148
+
149
+ return $currency;
150
  }
151
 
152
  /**
155
  */
156
  public function getCurrentPage()
157
  {
158
+ try {
159
+ $orderId = $this->request->getActionName() === 'success' ? $this->checkoutSession->getData('last_real_order_id') : null;
160
+ $module = $this->request->getModuleName();
161
+
162
+ $productId = 0;
163
+
164
+ //Product page
165
+ if ($module === 'catalog' && $this->currentProductRegistry) {
166
+ $productId = $this->currentProductRegistry->getId();
167
+ $latestViewedProducts = $this->coreSession->getUserViewedProducts();
168
+ if (!empty($latestViewedProducts)) {
169
+ $latestViewedProducts .= ',' . $productId;
170
+ $this->coreSession->setUserViewedProducts($latestViewedProducts);
171
+ } else {
172
+ $this->coreSession->setUserViewedProducts($productId);
173
+ }
174
+ $this->coreSession->setHistory(true);
175
  }
 
 
176
 
177
+ // Category page
178
+ if ($module === 'catalog' && $this->currentCategoryRegistry) {
179
+ // check if the category is a root category to avoid it
180
+ if ($this->catalogLayer->getCurrentCategory()->getLevel() !== "1") {
181
+
182
+ $catName = $this->coreSession->getLastVisitedCategoryName();
183
+ $catLink = $this->coreSession->getLastVisitedCategoryLink();
184
+
185
+ $currentCategoryName = $this->catalogLayer->getCurrentCategory()->getName();
186
+ $currentCategoryLink = $this->catalogLayer->getCurrentCategory()->getUrl();
187
+
188
+ if (!empty($catName) && !empty($catLink)) {
189
+ $catName .= ',' . $currentCategoryName;
190
+ $catLink .= ',' . $currentCategoryLink;
191
+ $this->coreSession->setLastVisitedCategoryName($catName);
192
+ $this->coreSession->setLastVisitedCategoryLink($catLink);
193
+ } else {
194
+ $this->coreSession->setLastVisitedCategoryName($currentCategoryName);
195
+ $this->coreSession->setLastVisitedCategoryLink($currentCategoryLink);
196
+ }
197
+ $this->coreSession->setHistory(true);
198
  }
 
199
  }
 
200
 
201
+ $current = array(
202
+ 'currentUrl' => $this->coreUrlHelper->getCurrentUrl(),
203
+ 'orderId' => $orderId,
204
+ 'currentPageType' => $this->getPageType(),
205
+ 'product' => $this->getProductInformation($productId)
206
+ );
207
+ } catch (Exception $exception) {
208
+ $this->exceptionHandler->logException($exception);
209
+
210
+ $current = array(
211
+ 'currentUrl' => null,
212
+ 'orderId' => null,
213
+ 'currentPageType' => null,
214
+ 'product' => $this->getDefaultProduct()
215
+ );
216
+ }
217
 
218
  return $current;
219
  }
223
  */
224
  public function getPageType()
225
  {
 
 
 
226
  $type = null;
227
+ try {
228
+ $controller = $this->request->getControllerName();
229
+ $action = $this->request->getActionName();
230
+ $actionFullName = $this->frontController->getAction()->getFullActionName();
231
+
232
+ switch ($controller) {
233
+ case 'index':
234
+ if ($actionFullName == 'cms_index_index') {
235
+ $type = 'home';
236
+ } else {
237
+ $type = 'other';
238
+ }
239
+ break;
240
+ case 'account':
241
+ if ($action == 'login') {
242
+ $type = 'login';
243
+ } else if ($action == 'create') {
244
+ $type = 'register';
245
+ } else {
246
+ $type = 'other';
247
+ }
248
+ break;
249
+ case 'product':
250
+ $type = 'product';
251
+ break;
252
+ case 'cart':
253
+ $type = 'basket';
254
+ break;
255
+ case 'category':
256
+ $type = 'category';
257
+ break;
258
+ case 'onepage':
259
+ if ($action != 'success') {
260
+ $type = 'checkout';
261
+ } else {
262
+ $type = 'complete';
263
+ }
264
+ break;
265
+ case 'multishipping':
266
+ if ($action != 'success') {
267
+ $type = 'checkout';
268
+ } else {
269
+ $type = 'complete';
270
+ }
271
+ break;
272
+ default:
273
+ $type = 'other';
274
+ }
275
+
276
+ } catch (Exception $exception) {
277
+ $this->exceptionHandler->logException($exception);
278
  }
279
 
280
  return $type;
281
  }
282
 
283
  /**
284
+ * @return array
285
  */
286
+ private function getDefaultCart()
287
  {
288
+ return array(
 
 
 
 
 
 
 
 
 
 
 
289
  'dateUpd' => null,
290
+ 'totalPrice' => null,
291
+ 'totalProducts' => null,
292
+ 'products' => $this->getDefaultProduct(),
293
+ 'taxes' => array(),
294
+ 'promocode' => $this->getDefaultPromocode(),
295
+ 'totalPromocodeDiscount' => null
296
  );
297
+ }
298
 
299
+ /**
300
+ * Get current order, all cart information
301
+ */
302
+ public function getCurrentOrder()
303
+ {
304
+ $cart = $this->getDefaultCart();
305
+ try {
306
+ if ($this->getPageType() == 'complete') {
307
+ return null;
308
+ }
 
 
 
 
309
 
310
+ $order = $this->checkoutSession->getQuote();
311
+
312
+ $products = array();
313
+ $tax = array();
314
+ $discountAmount = 0;
315
+ $totalPrice = 0;
316
+ $totalProducts = 0;
317
+ $orderTotals = null;
318
+
319
+ if (isset($order)) {
320
+ $orderData = $order->getData();
321
+ $dateUpd = array_key_exists('updated_at', $orderData) ? $orderData['updated_at'] : null;
322
+ if ($order->hasItems()) {
323
+ $i = 0;
324
+ foreach ($order->getAllVisibleItems() as $item) {
325
+ $prodId = $item->getProductId();
326
+ $products[$i] = $this->getProductInformation($prodId);
327
+ $products[$i]['quantity'] = $item->getQty();
328
+ $products[$i]['productId'] = $item->getSku();
329
+
330
+ $prodObj = Mage::getModel('catalog/product')->load((int)$prodId);
331
+ if (empty($prodObj)) {
332
+ $this->exceptionHandler->logMessage('Product information is missing for id=' . print_r($prodId, true), 'WARNING');
333
+ }
334
+ $finalPrice = $this->taxHelper->getPrice($prodObj, $prodObj->getFinalPrice(), true);
335
+ $products[$i]['productSubTotal'] = $this->coreHelper->currency($products[$i]['quantity'] * (float)$finalPrice, true, false);
336
+ $i++;
337
+ }
338
+
339
+ $orderTotals = $order->getTotals();
340
+ $rate = $order->getData('base_to_quote_rate');
341
+ $discountAmount = isset($orderTotals['discount']) ? $orderTotals['discount']->getValue() / $rate : 0;
342
+ $totalPrice = $orderTotals['grand_total']->getValue() / $rate;
343
+ $shippingExclTaxes = 0;
344
+ if(isset($orderTotals['shipping'])){
345
+ $shippingExclTaxes = $orderTotals['shipping']->getValue();
346
+ }
347
+ $totalProducts = $totalPrice - $shippingExclTaxes;
348
+
349
+ if (isset($orderTotals['tax'])) {
350
+ $taxValue = $orderTotals['tax']->getValue() / $rate;
351
+ $totalTax = array(
352
+ 'name' => 'Total Tax',
353
+ 'taxValue' => $this->coreHelper->currency($taxValue, true, false)
354
+ );
355
+
356
+ $tax[] = $totalTax;
357
+ }
358
  }
359
 
360
+ $cart['dateUpd'] = $dateUpd;
361
+ $cart['totalPrice'] = ($totalPrice != 0 && $totalProducts != 0) ? $this->coreHelper->currency($totalPrice, true, false) : null;
362
+ $cart['totalProducts'] = ($totalPrice != 0 && $totalProducts != 0) ? strip_tags($this->checkoutHelper->formatPrice($totalProducts)) : null;
363
+ $cart['products'] = $products;
364
+ $cart['taxes'] = $tax;
365
+ $cart['promocode'] = $this->getPromocode($order);
366
+ $cart['totalPromocodeDiscount'] = ($totalPrice != 0 && $totalProducts != 0) ? $this->coreHelper->currency(abs($discountAmount), true, false) : null;
367
  }
368
+ } catch (Exception $exception) {
369
+ $this->exceptionHandler->logException($exception);
 
 
 
 
 
 
370
  }
371
 
372
  return $cart;
373
  }
374
 
375
+ /**
376
+ * @return array
377
+ */
378
+ private function getDefaultPromocode()
379
+ {
380
+ return array(
381
+ 'code' => null,
382
+ 'name' => null,
383
+ 'type' => null,
384
+ 'value' => null
385
+ );
386
+ }
387
 
388
  /**
389
  * Get promocodes applied for the current order
390
  */
391
  public function getPromocode($order)
392
  {
393
+ $currentPromocode = $this->getDefaultPromocode();
 
 
 
394
 
395
+ try {
396
+ $appliedRuleIds = $order->getAppliedRuleIds();
397
+ if (!isset($appliedRuleIds) || empty($appliedRuleIds)) {
398
+ return $currentPromocode;
399
+ }
400
 
401
+ $ruleIds = explode(',', $appliedRuleIds);
402
+ $ruleIds = array_unique($ruleIds);
403
+
404
+ foreach ($ruleIds as $ruleId) {
405
+ $rule = Mage::getModel('salesrule/rule');
406
+ $rule->load($ruleId);
407
+ $ruleId = $rule->getId();
408
+ $ruleCouponCode = $rule->getData('coupon_code');
409
+ if (!empty($ruleId) && !empty($ruleCouponCode)) {
410
+ $type = $rule->getData('simple_action');
411
+ $promoCodeValue = $rule->getData('discount_amount');
412
+ if (strrpos($type, 'fixed') !== false) {
413
+ $promoCodeValue = $this->coreHelper->currency(abs($promoCodeValue), true, false);
414
+ }
415
+
416
+ $currentPromocode = array(
417
+ 'code' => $ruleCouponCode,
418
+ 'name' => $rule->getData('name'),
419
+ 'type' => $type,
420
+ 'value' => $promoCodeValue
421
+ );
422
 
423
+ //return first promocode with a valid coupon code
424
+ return $currentPromocode;
425
+ }
426
  }
427
+ } catch (Exception $exception) {
428
+ $this->exceptionHandler->logException($exception);
429
  }
430
 
431
+ // no promocode with a valid coupon code was found
432
+ return $currentPromocode;
 
 
 
 
433
  }
434
 
435
  /**
436
+ * @return array
437
  */
438
+ private function getDefaultProduct()
439
  {
440
+ return array(
441
  'productId' => null,
442
  'description' => null,
443
+ 'descriptionShort' => null,
444
  'images' => array(
445
  'fullImagePath' => null,
446
  'partialImagePath' => null,
450
  'priceCurrent' => null,
451
  'priceDiscount' => null,
452
  'priceWithoutDiscount' => null,
453
+ 'productLink' => null,
454
+ 'category' => null
455
  );
456
+ }
457
 
458
+ /**
459
+ * Build product structure used used in currentPage and cart
460
+ */
461
+ public function getProductInformation($id)
462
+ {
463
+ $prod = $this->getDefaultProduct();
464
+ try {
465
+ if (empty($id)) {
466
+ return $prod;
467
+ }
468
 
469
+ $product = Mage::getModel('catalog/product')->load((int)$id);
470
+ $category = null;
471
+ // get top parent category of current product
472
+ $categoryIds = $product->getCategoryIds();
473
+ if (count($categoryIds) > 0) {
474
+ $category = $this->catalogCategory->load((int)$categoryIds[0]);
475
+ $catParent = $this->getTopParentCategory($category);
476
+ $category = empty($catParent) ? $category->getName() : $catParent->getName();
477
+ }
478
 
479
+ $imgFullPath = $this->catalogMedia->getMediaUrl($product->getImage());
480
+ $imgPartialPath = $this->catalogMedia->getMediaShortUrl($product->getImage());
481
+
482
+ $finalPrice = $this->taxHelper->getPrice($product, $product->getFinalPrice(), true);
483
+ $originalPrice = $this->taxHelper->getPrice($product, $product->getPrice(), true);
484
+ $productSku = $product->getData('sku');
485
+ $prod = array(
486
+ 'productId' => !empty($productSku) ? $productSku : $id,
487
+ 'description' => $product->getData('description'),
488
+ 'descriptionShort' => $product->getData('short_description'),
489
+ 'images' => array(
490
+ 'fullImagePath' => $imgFullPath,
491
+ 'partialImagePath' => $imgPartialPath,
492
+ ),
493
+ 'manufacturerName' => null,
494
+ 'name' => $product->getName(),
495
+ 'priceCurrent' => $this->coreHelper->currency($finalPrice, true, false),
496
+ 'priceDiscount' => $this->coreHelper->currency(($originalPrice - $finalPrice), true, false),
497
+ 'priceWithoutDiscount' => $this->coreHelper->currency($originalPrice, true, false),
498
+ 'productLink' => $product->getProductUrl(true),
499
+ 'category' => $category
500
+ );
501
+ } catch (Exception $exception) {
502
+ $this->exceptionHandler->logException($exception);
503
+ }
504
 
505
  return $prod;
506
  }
507
 
508
  /**
509
+ * Get top-most parent of a specific category
510
+ *
511
+ * @param $category
512
+ * @return null | instance of category entity
513
  */
514
+ private function getTopParentCategory($category)
515
+ {
516
+ $topParent = null;
517
+ try {
518
+ $path = $category->getPath(); // gets list of category ids separated by slashes, eg: rootCategoryId/defaultCategoryId/womenCategoryId/newarrivalsCategoryId
519
+ $ids = explode('/', $path);
520
+
521
+ /*
522
+ As "Root Category" and "Default Category" are not displayed in the breadcrumb, so we look the following category in the hierarchy
523
+ If none exists, it means that $category is already a top level one, so it doesn't have a parent
524
+ */
525
+ if (isset($ids[2])) {
526
+ $topParent = $this->catalogCategory->setStoreId($this->store->getId())->load($ids[2]);
527
+ }
528
+ } catch (Exception $exception) {
529
+ $this->exceptionHandler->logException($exception);
530
+ }
531
+
532
+ return $topParent;
533
+ }
534
+
535
+ /**
536
+ * Get formatted array for lastVisitedCategory
537
+ * @return array
538
+ */
539
+ private function getLastVisitedcategory()
540
+ {
541
+ try {
542
+ $session = Mage::getSingleton("core/session", array("name" => "frontend"));
543
+
544
+ // update category on product and category page
545
+ if ($this->currentProductRegistry || $this->currentCategoryRegistry) {
546
+
547
+ $category = null;
548
+ //product page
549
+ if ($this->currentProductRegistry) {
550
+ //get categories of current product
551
+ $productId = $this->currentProductRegistry->getId();
552
+ $product = Mage::getModel('catalog/product')->load((int)$productId);
553
+ $categoryIds = $product->getCategoryIds();
554
+
555
+ if (count($categoryIds) > 0) {
556
+ $category = $this->catalogCategory->load((int)$categoryIds[0]);
557
+ $catParent = $this->getTopParentCategory($category);
558
+ $category = empty($catParent) ? $category : $catParent;
559
+ }
560
+ } else {
561
+ //category page
562
+ $catId = $this->currentCategoryRegistry->getId();
563
+ $category = $this->catalogCategory->load((int)$catId);
564
+ }
565
+
566
+ if (isset($category)) {
567
+ $categoryName = $category->getName();
568
+ $categoryLink = $category->getUrl();
569
+
570
+ // save category name and url in session
571
+ $session->setData('lastVisitedCategoryName', $categoryName);
572
+ $session->setData('lastVisitedCategoryLink', $categoryLink);
573
+ } else {
574
+ // if product has no category, retrieve information from session
575
+ $categoryName = $session->getData('lastVisitedCategoryName');
576
+ $categoryLink = $session->getData('lastVisitedCategoryLink');
577
+ }
578
+ } else {
579
+ // retrieve category information from session, if not on product or category page
580
+ $categoryName = $session->getData('lastVisitedCategoryName');
581
+ $categoryLink = $session->getData('lastVisitedCategoryLink');
582
+ }
583
+
584
+ $lastVisitedCategory = array(
585
+ 'name' => isset($categoryName) ? $categoryName : null,
586
+ 'link' => isset($categoryLink) ? $categoryLink : null
587
+ );
588
+ } catch (Exception $exception) {
589
+ $this->exceptionHandler->logException($exception);
590
+
591
+ $lastVisitedCategory = array(
592
  'name' => null,
593
  'link' => null
594
  );
595
+ }
596
+
597
+ return $lastVisitedCategory;
598
+ }
599
 
600
+ /**
601
+ * Get user history - products history and last visited category
602
+ */
603
+ public function getUserHistory()
604
+ {
605
+ try {
606
+ $history = array();
607
+ $hasHistory = $this->coreSession->getHistory();
608
+ if (!$hasHistory) {
609
+ $history['productHistory'] = array();
610
+ $history['lastVisitedCategory'] = array(
611
+ 'name' => null,
612
+ 'link' => null
613
+ );
614
+ } else {
615
+ $latestViewedProducts = $this->coreSession->getUserViewedProducts();
616
  $productHistory = array();
617
+ if (!empty($latestViewedProducts)) {
618
+ $productList = array_unique(explode(',', $latestViewedProducts));
619
+ foreach ($productList as $productId) {
620
+ $productHistory[] = $this->getProductInformation($productId);
621
+ }
622
  }
623
+
624
  $history['productHistory'] = $productHistory;
625
+ $history['lastVisitedCategory'] = $this->getLastVisitedcategory();
626
  }
627
+
628
+ } catch (Exception $exception) {
629
+ $this->exceptionHandler->logException($exception);
630
+ $history = array(
631
+ 'productHistory' => array(),
632
+ 'lastVisitedCategory' => array(
 
 
 
 
 
 
 
633
  'name' => null,
634
  'link' => null
635
+ )
636
+ );
637
  }
638
+
639
  return $history;
640
  }
641
 
650
  'lastName' => null
651
  );
652
 
653
+ try {
654
+ if ($this->customerSession->isLoggedIn()) {
655
+ $customer = $this->customerSession->getCustomer();
656
+ $customerMiddleName = $customer->getMiddlename();
657
+ $customerInfo = array(
658
+ 'email' => $customer->getEmail(),
659
+ 'firstName' => $customer->getFirstname() . (!empty($customerMiddleName) ? ' ' . $customerMiddleName : ''),
660
+ 'lastName' => $customer->getLastname()
661
+ );
662
+ }
663
+ } catch (Exception $exception) {
664
+ $this->exceptionHandler->logException($exception);
665
  }
666
 
667
  return $customerInfo;
668
  }
669
+
670
  }
671
+
app/code/community/VeInteractive/VePlatform/Observer/AdminUserLoadAfter.php CHANGED
@@ -1,29 +1,51 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Observer_AdminUserLoadAfter {
 
 
 
 
 
 
 
 
4
 
5
- public function checkInstallation($observer) {
6
- $isAjax = Mage::app()->getRequest()->isXmlHttpRequest();
7
- if(!$isAjax) {
8
- $this->checkModuleInstallation();
9
  }
10
- }
11
 
12
- private function checkModuleInstallation() {
13
- $module_installed = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::MODULE_INSTALLED);
 
 
 
 
 
 
14
 
15
- if(!$module_installed) {
16
- Mage::getConfig()->saveConfig(VeInteractive_VePlatform_Helper_Data::MODULE_INSTALLED, true);
17
- Mage::getConfig()->saveConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL, 1, 'default', 0);
18
- Mage::app()->getCacheInstance()->cleanType("config");
19
- Mage::getSingleton('admin/session')->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
 
 
 
 
 
 
 
 
 
20
 
21
- $optionsUrl = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/veplatform_options");
22
 
23
- $response = Mage::app()->getResponse();
24
 
25
- $response->setRedirect($optionsUrl)->sendResponse();
26
- exit();
 
 
 
 
27
  }
28
- }
29
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Observer_AdminUserLoadAfter
4
+ {
5
+ private $exceptionHandler;
6
+ public function __construct()
7
+ {
8
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
9
+ if (file_exists($filePath)) {
10
+ require_once $filePath;
11
+ }
12
 
13
+ $this->exceptionHandler = new ExceptionHandler();
 
 
 
14
  }
 
15
 
16
+ public function checkInstallation($observer)
17
+ {
18
+ try {
19
+ $isAjax = Mage::app()->getRequest()->isXmlHttpRequest();
20
+ if (!$isAjax) {
21
+ $this->checkModuleInstallation();
22
+ }
23
+ } catch (Exception $exception) {
24
 
25
+ $this->exceptionHandler->logException($exception);
26
+ }
27
+ }
28
+
29
+ private function checkModuleInstallation()
30
+ {
31
+ try {
32
+ $module_installed = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::MODULE_INSTALLED);
33
+
34
+ if (!$module_installed && $this->exceptionHandler->validate()) {
35
+ Mage::getConfig()->saveConfig(VeInteractive_VePlatform_Helper_Data::MODULE_INSTALLED, true);
36
+ Mage::getConfig()->saveConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL, 1, 'default', 0);
37
+ Mage::app()->getCacheInstance()->cleanType("config");
38
+ Mage::getSingleton('admin/session')->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
39
 
40
+ $optionsUrl = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/veplatform_options");
41
 
42
+ $response = Mage::app()->getResponse();
43
 
44
+ $response->setRedirect($optionsUrl)->sendResponse();
45
+ exit();
46
+ }
47
+ } catch (Exception $exception) {
48
+ $this->exceptionHandler->logException($exception);
49
+ }
50
  }
 
51
  }
app/code/community/VeInteractive/VePlatform/Observer/Layout.php CHANGED
@@ -1,54 +1,57 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Observer_Layout {
 
4
 
5
- private $blocks;
6
 
7
- public function __construct(){
 
8
  $this->blocks = array(
9
  array(
10
- 'block' => 'veplatform/vetag',
11
- 'name' => 'veplatform.vetag',
12
  'parent' => 'before_body_end'
13
  ),
14
  array(
15
- 'block' => 'veplatform/vepixel',
16
- 'name' => 'veplatform.vepixel',
17
  'parent' => 'content'
18
  ),
19
  array(
20
  'block' => 'veplatform/vemaster',
21
- 'name' => 'veplatform.vemaster',
22
  'parent' => 'content'
23
  )
24
  );
25
- }
 
 
 
 
 
26
 
27
- public function updateLayout(Varien_Event_Observer $observer) {
28
- // Only for FrontEnd.
29
- if($observer->getLayout()->getArea() === 'frontend') {
30
 
31
- $layout = $observer->getLayout();
32
- if($layout) {
33
 
34
- foreach ($this->blocks as $setting) {
35
- // Avoid adding the block twice.
36
 
37
- if(!$layout->getBlock($setting['block'])) {
38
 
39
- $block = $layout->createBlock( $setting['block'], $setting['name']);
40
-
41
- if($block) {
42
- $parent = $layout->getBlock($setting['parent']);
43
- if($parent) {
44
- $parent->append($block);
45
  }
46
  }
47
- }
48
- }
49
 
50
- }
51
-
 
52
  }
53
- }
54
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Observer_Layout
4
+ {
5
 
6
+ private $blocks;
7
 
8
+ public function __construct()
9
+ {
10
  $this->blocks = array(
11
  array(
12
+ 'block' => 'veplatform/vetag',
13
+ 'name' => 'veplatform.vetag',
14
  'parent' => 'before_body_end'
15
  ),
16
  array(
17
+ 'block' => 'veplatform/vepixel',
18
+ 'name' => 'veplatform.vepixel',
19
  'parent' => 'content'
20
  ),
21
  array(
22
  'block' => 'veplatform/vemaster',
23
+ 'name' => 'veplatform.vemaster',
24
  'parent' => 'content'
25
  )
26
  );
27
+ }
28
+
29
+ public function updateLayout(Varien_Event_Observer $observer)
30
+ {
31
+ // Only for FrontEnd.
32
+ if ($observer->getLayout()->getArea() === 'frontend') {
33
 
34
+ $layout = $observer->getLayout();
35
+ if ($layout) {
 
36
 
37
+ foreach ($this->blocks as $setting) {
38
+ // Avoid adding the block twice.
39
 
40
+ if (!$layout->getBlock($setting['block'])) {
 
41
 
42
+ $block = $layout->createBlock($setting['block'], $setting['name']);
43
 
44
+ if ($block) {
45
+ $parent = $layout->getBlock($setting['parent']);
46
+ if ($parent) {
47
+ $parent->append($block);
48
+ }
49
+ }
50
  }
51
  }
 
 
52
 
53
+ }
54
+
55
+ }
56
  }
 
57
  }
app/code/community/VeInteractive/VePlatform/Observer/ThanksPage.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
 
3
- class VeInteractive_VePlatform_Observer_ThanksPage {
 
4
 
5
- public function showPixel() {
6
- $journeyPixel = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL);
7
- if($journeyPixel) {
8
- Mage::getSingleton('core/session')->setShowPixel(true);
 
 
9
  }
10
- }
11
  }
1
  <?php
2
 
3
+ class VeInteractive_VePlatform_Observer_ThanksPage
4
+ {
5
 
6
+ public function showPixel()
7
+ {
8
+ $journeyPixel = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL);
9
+ if ($journeyPixel) {
10
+ Mage::getSingleton('core/session')->setShowPixel(true);
11
+ }
12
  }
 
13
  }
app/code/community/VeInteractive/VePlatform/composer.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Ve for Magento",
3
+ "description": "The only automated marketing solution to solve your abandonment & conversion problems at every stage in the customer's journey.",
4
+ "homepage": "https://www.veinteractive.com/",
5
+ "authors": [
6
+ {
7
+ "name": "Ve Interactive"
8
+ }
9
+ ],
10
+ "license": "proprietary",
11
+ "require": {
12
+ "microsoft/application-insights": "*"
13
+ }
14
+ }
app/code/community/VeInteractive/VePlatform/composer.lock ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_readme": [
3
+ "This file locks the dependencies of your project to a known state",
4
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
+ "This file is @generated automatically"
6
+ ],
7
+ "hash": "ae83ca4057aa2724dc379a041f674a04",
8
+ "content-hash": "035e185c2cc28a40c9fb55f792591235",
9
+ "packages": [
10
+ {
11
+ "name": "guzzlehttp/guzzle",
12
+ "version": "6.2.0",
13
+ "source": {
14
+ "type": "git",
15
+ "url": "https://github.com/guzzle/guzzle.git",
16
+ "reference": "d094e337976dff9d8e2424e8485872194e768662"
17
+ },
18
+ "dist": {
19
+ "type": "zip",
20
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
21
+ "reference": "d094e337976dff9d8e2424e8485872194e768662",
22
+ "shasum": ""
23
+ },
24
+ "require": {
25
+ "guzzlehttp/promises": "~1.0",
26
+ "guzzlehttp/psr7": "~1.1",
27
+ "php": ">=5.5.0"
28
+ },
29
+ "require-dev": {
30
+ "ext-curl": "*",
31
+ "phpunit/phpunit": "~4.0",
32
+ "psr/log": "~1.0"
33
+ },
34
+ "type": "library",
35
+ "extra": {
36
+ "branch-alias": {
37
+ "dev-master": "6.2-dev"
38
+ }
39
+ },
40
+ "autoload": {
41
+ "files": [
42
+ "src/functions_include.php"
43
+ ],
44
+ "psr-4": {
45
+ "GuzzleHttp\\": "src/"
46
+ }
47
+ },
48
+ "notification-url": "https://packagist.org/downloads/",
49
+ "license": [
50
+ "MIT"
51
+ ],
52
+ "authors": [
53
+ {
54
+ "name": "Michael Dowling",
55
+ "email": "mtdowling@gmail.com",
56
+ "homepage": "https://github.com/mtdowling"
57
+ }
58
+ ],
59
+ "description": "Guzzle is a PHP HTTP client library",
60
+ "homepage": "http://guzzlephp.org/",
61
+ "keywords": [
62
+ "client",
63
+ "curl",
64
+ "framework",
65
+ "http",
66
+ "http client",
67
+ "rest",
68
+ "web service"
69
+ ],
70
+ "time": "2016-03-21 20:02:09"
71
+ },
72
+ {
73
+ "name": "guzzlehttp/promises",
74
+ "version": "1.2.0",
75
+ "source": {
76
+ "type": "git",
77
+ "url": "https://github.com/guzzle/promises.git",
78
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
79
+ },
80
+ "dist": {
81
+ "type": "zip",
82
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
83
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
84
+ "shasum": ""
85
+ },
86
+ "require": {
87
+ "php": ">=5.5.0"
88
+ },
89
+ "require-dev": {
90
+ "phpunit/phpunit": "~4.0"
91
+ },
92
+ "type": "library",
93
+ "extra": {
94
+ "branch-alias": {
95
+ "dev-master": "1.0-dev"
96
+ }
97
+ },
98
+ "autoload": {
99
+ "psr-4": {
100
+ "GuzzleHttp\\Promise\\": "src/"
101
+ },
102
+ "files": [
103
+ "src/functions_include.php"
104
+ ]
105
+ },
106
+ "notification-url": "https://packagist.org/downloads/",
107
+ "license": [
108
+ "MIT"
109
+ ],
110
+ "authors": [
111
+ {
112
+ "name": "Michael Dowling",
113
+ "email": "mtdowling@gmail.com",
114
+ "homepage": "https://github.com/mtdowling"
115
+ }
116
+ ],
117
+ "description": "Guzzle promises library",
118
+ "keywords": [
119
+ "promise"
120
+ ],
121
+ "time": "2016-05-18 16:56:05"
122
+ },
123
+ {
124
+ "name": "guzzlehttp/psr7",
125
+ "version": "1.3.1",
126
+ "source": {
127
+ "type": "git",
128
+ "url": "https://github.com/guzzle/psr7.git",
129
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
130
+ },
131
+ "dist": {
132
+ "type": "zip",
133
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
134
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
135
+ "shasum": ""
136
+ },
137
+ "require": {
138
+ "php": ">=5.4.0",
139
+ "psr/http-message": "~1.0"
140
+ },
141
+ "provide": {
142
+ "psr/http-message-implementation": "1.0"
143
+ },
144
+ "require-dev": {
145
+ "phpunit/phpunit": "~4.0"
146
+ },
147
+ "type": "library",
148
+ "extra": {
149
+ "branch-alias": {
150
+ "dev-master": "1.4-dev"
151
+ }
152
+ },
153
+ "autoload": {
154
+ "psr-4": {
155
+ "GuzzleHttp\\Psr7\\": "src/"
156
+ },
157
+ "files": [
158
+ "src/functions_include.php"
159
+ ]
160
+ },
161
+ "notification-url": "https://packagist.org/downloads/",
162
+ "license": [
163
+ "MIT"
164
+ ],
165
+ "authors": [
166
+ {
167
+ "name": "Michael Dowling",
168
+ "email": "mtdowling@gmail.com",
169
+ "homepage": "https://github.com/mtdowling"
170
+ }
171
+ ],
172
+ "description": "PSR-7 message implementation",
173
+ "keywords": [
174
+ "http",
175
+ "message",
176
+ "stream",
177
+ "uri"
178
+ ],
179
+ "time": "2016-06-24 23:00:38"
180
+ },
181
+ {
182
+ "name": "microsoft/application-insights",
183
+ "version": "0.3.3",
184
+ "source": {
185
+ "type": "git",
186
+ "url": "https://github.com/Microsoft/ApplicationInsights-PHP.git",
187
+ "reference": "0e711894751f0d4fe9a66b3dbaad28b7be8adc13"
188
+ },
189
+ "dist": {
190
+ "type": "zip",
191
+ "url": "https://api.github.com/repos/Microsoft/ApplicationInsights-PHP/zipball/0e711894751f0d4fe9a66b3dbaad28b7be8adc13",
192
+ "reference": "0e711894751f0d4fe9a66b3dbaad28b7be8adc13",
193
+ "shasum": ""
194
+ },
195
+ "require": {
196
+ "guzzlehttp/guzzle": ">=5.0 <=6.2.0",
197
+ "php": ">=5.4.0"
198
+ },
199
+ "require-dev": {
200
+ "evert/phpdoc-md": "~0.0.7",
201
+ "phpunit/phpunit": "~4.3"
202
+ },
203
+ "type": "library",
204
+ "autoload": {
205
+ "psr-4": {
206
+ "ApplicationInsights\\": "ApplicationInsights/"
207
+ }
208
+ },
209
+ "notification-url": "https://packagist.org/downloads/",
210
+ "license": [
211
+ "MIT"
212
+ ],
213
+ "description": "This project extends the Application Insights API surface to support PHP.",
214
+ "homepage": "https://github.com/Microsoft/ApplicationInsights-PHP",
215
+ "keywords": [
216
+ "Insights",
217
+ "log",
218
+ "logging",
219
+ "monitoring",
220
+ "telemetry"
221
+ ],
222
+ "time": "2016-05-25 04:03:33"
223
+ },
224
+ {
225
+ "name": "psr/http-message",
226
+ "version": "1.0.1",
227
+ "source": {
228
+ "type": "git",
229
+ "url": "https://github.com/php-fig/http-message.git",
230
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
231
+ },
232
+ "dist": {
233
+ "type": "zip",
234
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
235
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
236
+ "shasum": ""
237
+ },
238
+ "require": {
239
+ "php": ">=5.3.0"
240
+ },
241
+ "type": "library",
242
+ "extra": {
243
+ "branch-alias": {
244
+ "dev-master": "1.0.x-dev"
245
+ }
246
+ },
247
+ "autoload": {
248
+ "psr-4": {
249
+ "Psr\\Http\\Message\\": "src/"
250
+ }
251
+ },
252
+ "notification-url": "https://packagist.org/downloads/",
253
+ "license": [
254
+ "MIT"
255
+ ],
256
+ "authors": [
257
+ {
258
+ "name": "PHP-FIG",
259
+ "homepage": "http://www.php-fig.org/"
260
+ }
261
+ ],
262
+ "description": "Common interface for HTTP messages",
263
+ "homepage": "https://github.com/php-fig/http-message",
264
+ "keywords": [
265
+ "http",
266
+ "http-message",
267
+ "psr",
268
+ "psr-7",
269
+ "request",
270
+ "response"
271
+ ],
272
+ "time": "2016-08-06 14:39:51"
273
+ }
274
+ ],
275
+ "packages-dev": [],
276
+ "aliases": [],
277
+ "minimum-stability": "stable",
278
+ "stability-flags": [],
279
+ "prefer-stable": false,
280
+ "prefer-lowest": false,
281
+ "platform": [],
282
+ "platform-dev": []
283
+ }
app/code/community/VeInteractive/VePlatform/controllers/Adminhtml/CustomController.php CHANGED
@@ -1,72 +1,103 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- class VeInteractive_VePlatform_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action {
4
-
5
- public function installVePlatformAction() {
6
- $params = $this->getDataAction();
7
- $helper = Mage::helper('VeInteractive_VePlatform');
8
- $config = Mage::getConfig();
9
-
10
- $jsonResponse = $helper->install($params);
11
- if($jsonResponse) {
12
- $response = json_decode($jsonResponse);
13
- if($response && isset($response->HtmlView)) {
14
-
15
- //if we received the tag, token, pixel - we save them in db
16
- if(isset($response->URLTag) && $response->URLTag != ""
17
- && isset($response->URLPixel) && $response->URLPixel != ""
18
- && isset($response->Token) && $response->Token != ""
19
- ) {
20
- $config->saveConfig(VeInteractive_VePlatform_Helper_Data::TOKEN, $response->Token, 'default', 0);
21
- $config->saveConfig(VeInteractive_VePlatform_Helper_Data::TAG_URL, $response->URLTag, 'default', 0);
22
- $config->saveConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL, $response->URLPixel, 'default', 0);
23
  }
24
 
25
- $config->saveConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL, 0, 'default', 0);
26
 
27
- Mage::dispatchEvent('adminhtml_cache_flush_all');
28
- Mage::app()->getCacheInstance()->flush();
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  echo json_encode($response);
31
- } else {
32
- $this->showError();
33
- }
34
- } else {
35
- $this->showError();
36
  }
37
 
38
- }
39
-
40
- private function showError() {
41
- $optionsUrl = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/veplatform_options");
42
- $message = Mage::helper('adminhtml')->__('Ve - Oops! An error has occured. <a href="%s">Please try again!</a>', $optionsUrl);
43
- Mage::getSingleton('adminhtml/session')->addWarning($message);
44
-
45
- $response = array(
46
- 'redirectUrl' => Mage::helper('adminhtml')->getUrl('/')
47
- );
48
-
49
- echo json_encode($response);
50
- }
51
-
52
- private function getDataAction() {
53
- $helper = Mage::helper('VeInteractive_VePlatform');
54
- $firstInstall = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL);
55
-
56
- // get data to send
57
- $data = array(
58
- 'ecommerce' => $helper->getPlatformName(),
59
- 'domain' => $helper->getBaseUrl(),
60
- 'language' => $helper->getLang(),
61
- 'email' => Mage::getSingleton('admin/session')->getUser()->getEmail(),
62
- 'phone' => Mage::getStoreConfig('general/store_information/phone'),
63
- 'merchant' => Mage::app()->getWebsite()->getName(),
64
- 'country' => Mage::getStoreConfig('general/country/default'),
65
- 'currency' => Mage::app()->getBaseCurrencyCode(),
66
- 'isInstallFLow' => ($firstInstall == 1) ? 'true' : 'false'
67
- );
68
-
69
- return $data;
70
- }
71
 
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ $filePath = dirname(dirname(dirname(__FILE__))) . '/Helper/ExceptionHandler.php';
3
+ if (file_exists($filePath)) {
4
+ require_once $filePath;
5
+ }
6
+
7
+ class VeInteractive_VePlatform_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ private $helper;
10
+ private $exceptionHandler;
11
+
12
+ public function installVePlatformAction()
13
+ {
14
+ $this->exceptionHandler = new ExceptionHandler();
15
+
16
+ if ($this->exceptionHandler->validate()) {
17
+ $this->helper = Mage::helper('VeInteractive_VePlatform');
18
+ $params = $this->getDataAction();
19
+ $config = Mage::getConfig();
20
+
21
+ $jsonResponse = $this->helper->install($params);
22
+ if ($jsonResponse) {
23
+ $response = json_decode($jsonResponse);
24
+ if ($response && isset($response->HtmlView)) {
25
+
26
+ //if we received the tag, token, pixel - we save them in db
27
+ if (isset($response->URLTag) && $response->URLTag != ""
28
+ && isset($response->URLPixel) && $response->URLPixel != ""
29
+ && isset($response->Token) && $response->Token != ""
30
+ ) {
31
+
32
+ $modulesInstalled = Mage::getConfig()->getNode('modules')->children();
33
+ $modulesInstalled = json_encode($modulesInstalled);
34
+ $this->exceptionHandler->logMessage('Modules installed '. print_r($modulesInstalled, true), 'INFO');
35
+
36
+ $config->saveConfig(VeInteractive_VePlatform_Helper_Data::TOKEN, $response->Token, 'default', 0);
37
+ $config->saveConfig(VeInteractive_VePlatform_Helper_Data::TAG_URL, $response->URLTag, 'default', 0);
38
+ $config->saveConfig(VeInteractive_VePlatform_Helper_Data::PIXEL_URL, $response->URLPixel, 'default', 0);
39
+
40
+ if ( isset($response->VeDataActive) && $response->VeDataActive != "") {
41
+ $config->saveConfig(VeInteractive_VePlatform_Helper_Data::VEDATAACTIVE, $response->VeDataActive, 'default', 0);
42
+ }
43
+ }
44
+
45
+ $config->saveConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL, 0, 'default', 0);
46
 
47
+ Mage::dispatchEvent('adminhtml_cache_flush_all');
48
+ Mage::app()->getCacheInstance()->flush();
49
+
50
+ echo json_encode($response);
51
+ } else {
52
+ $this->showError();
53
+ $this->exceptionHandler->logMessage('Ve module was not activated. Response from WS after install call: ' . print_r($response, true), $this->exceptionHandler->level);
54
+ }
55
+ } else {
56
+ $this->showError();
57
+ $this->exceptionHandler->logMessage('Ve module was not activated. Install call to WS failed: ' . print_r($jsonResponse, true), $this->exceptionHandler->level);
58
+ }
59
+ } else {
60
+ $this->showError(true);
61
+ $this->exceptionHandler->logMessage('Ve module was not activated. ' . print_r($this->exceptionHandler->error['error'], true), $this->exceptionHandler->level);
 
 
 
 
 
62
  }
63
 
64
+ }
65
 
66
+ private function showError($specialMessage = false)
67
+ {
68
+ $optionsUrl = Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit/section/veplatform_options");
69
+ if ($specialMessage) {
70
+ $message = Mage::helper('adminhtml')->__($this->exceptionHandler->error['error'], $optionsUrl);
71
+ } else {
72
+ $message = Mage::helper('adminhtml')->__('Ve - Oops! An error has occured. <a href="%s">Please try again!</a>', $optionsUrl);
73
+ }
74
+ Mage::getSingleton('adminhtml/session')->addWarning($message);
75
+
76
+ $response = array(
77
+ 'redirectUrl' => Mage::helper('adminhtml')->getUrl('/')
78
+ );
79
 
80
  echo json_encode($response);
 
 
 
 
 
81
  }
82
 
83
+ private function getDataAction()
84
+ {
85
+ $firstInstall = Mage::getStoreConfig(VeInteractive_VePlatform_Helper_Data::FIRST_INSTALL);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
+ // get data to send
88
+ $data = array(
89
+ 'ecommerce' => $this->helper->getPlatformName(),
90
+ 'domain' => $this->helper->getBaseUrl(),
91
+ 'language' => $this->helper->getLang(),
92
+ 'email' => Mage::getSingleton('admin/session')->getUser()->getEmail(),
93
+ 'phone' => Mage::getStoreConfig('general/store_information/phone'),
94
+ 'merchant' => Mage::app()->getWebsite()->getName(),
95
+ 'country' => Mage::getStoreConfig('general/country/default'),
96
+ 'currency' => Mage::app()->getBaseCurrencyCode(),
97
+ 'isInstallFLow' => ($firstInstall == 1) ? 'true' : 'false'
98
+ );
99
+
100
+ return $data;
101
+ }
102
+
103
+ }
app/code/community/VeInteractive/VePlatform/controllers/IndexController.php CHANGED
@@ -1,12 +1,49 @@
1
  <?php
2
- class VeInteractive_VePlatform_IndexController extends Mage_Core_Controller_Front_Action {
3
-
 
 
 
 
 
 
4
  private $data;
5
-
 
6
  public function updateCartAction()
7
  {
8
- sleep(1);
9
- $this->data = Mage::getModel('VeInteractive_VePlatform/data');
10
- die(Mage::helper('core')->jsonEncode($this->data->getCurrentOrder()));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
  }
1
  <?php
2
+ $filePath = dirname(dirname(__FILE__)) . '/Helper/ExceptionHandler.php';
3
+ if (file_exists($filePath)) {
4
+ require_once $filePath;
5
+ }
6
+
7
+ class VeInteractive_VePlatform_IndexController extends Mage_Core_Controller_Front_Action
8
+ {
9
+
10
  private $data;
11
+ private $exceptionHandler;
12
+
13
  public function updateCartAction()
14
  {
15
+ $this->exceptionHandler = new ExceptionHandler();
16
+ try {
17
+ sleep(1);
18
+ $this->data = Mage::getModel('VeInteractive_VePlatform_Model_Data',
19
+ array(
20
+ 'locale' => Mage::app()->getLocale(),
21
+ 'store' => Mage::app()->getStore(),
22
+ 'request' => Mage::app()->getRequest(),
23
+ 'coreSession' => Mage::getSingleton('core/session'),
24
+ 'catalogCategory' => Mage::getModel('catalog/category'),
25
+ 'catalogLayer' => Mage::getModel('catalog/layer'),
26
+ 'checkoutSession' => Mage::getModel('checkout/session'),
27
+ 'coreHelper' => Mage::helper('core'),
28
+ 'taxHelper' => Mage::helper('tax'),
29
+ 'currentProductRegistry' => Mage::registry('current_product'),
30
+ 'currentCategoryRegistry' => Mage::registry('current_category'),
31
+ 'customerSession' => Mage::getModel('customer/session'),
32
+ 'coreUrlHelper' => Mage::helper('core/url'),
33
+ 'checkoutHelper' => Mage::helper('checkout'),
34
+ 'directoryCurrency' => Mage::getModel('directory/currency'),
35
+ 'rule' => Mage::getModel('salesrule/rule'),
36
+ 'catalogMedia' => Mage::getModel('catalog/product_media_config'),
37
+ 'frontController' => Mage::app()->getFrontController()
38
+ )
39
+ );
40
+
41
+ $currentOrder = $this->data->getCurrentOrder();
42
+ $currentOrder = Mage::helper('core')->jsonEncode($currentOrder);
43
+ } catch (Exception $exception) {
44
+ $this->exceptionHandler->logException($exception);
45
+ $currentOrder = Mage::helper('core')->jsonEncode(null);
46
+ }
47
+ die($currentOrder);
48
  }
49
  }
app/code/community/VeInteractive/VePlatform/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <VeInteractive_VePlatform>
5
- <version>16.3.5.0</version>
6
  </VeInteractive_VePlatform>
7
  </modules>
8
  <global>
@@ -89,7 +89,7 @@
89
  <use>standard</use>
90
  <args>
91
  <module>VeInteractive_VePlatform</module>
92
- <frontname>veplatform</frontname>
93
  </args>
94
  </veplatform>
95
  </routers>
2
  <config>
3
  <modules>
4
  <VeInteractive_VePlatform>
5
+ <version>16.4.5.0</version>
6
  </VeInteractive_VePlatform>
7
  </modules>
8
  <global>
89
  <use>standard</use>
90
  <args>
91
  <module>VeInteractive_VePlatform</module>
92
+ <frontName>veplatform</frontName>
93
  </args>
94
  </veplatform>
95
  </routers>
app/code/community/VeInteractive/VePlatform/templates/vemaster.phtml CHANGED
@@ -1,3 +1,181 @@
1
- <script type='text/javascript' id='script-masterdata'>
2
- var masterData = <?php echo json_encode($this->getMasterData());?>;
3
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->showVeData()) : ?>
2
+ <script type="text/javascript" id="veplatform-masterdata">
3
+ var veData = <?php echo json_encode($this->getMasterData()); ?>;
4
+ </script>
5
+ <script type="text/javascript">
6
+ var baseDir = "<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>";
7
+
8
+ var veDataProcessor = veDataProcessor || {};
9
+ veDataProcessor = (function (window, document) {
10
+ 'use strict';
11
+
12
+ var addEvent = function (evnt, elem, func) {
13
+ if (elem.addEventListener) { // W3C compatibility
14
+ elem.addEventListener(evnt, func, false);
15
+ }
16
+ else if (elem.attachEvent) { // IE compatibility
17
+ elem.attachEvent("on" + evnt, func);
18
+ }
19
+ else { // No much to do
20
+ elem[evnt] = func;
21
+ }
22
+ };
23
+
24
+ /**
25
+ *
26
+ * @param {type} elems
27
+ * @param {string|array} types
28
+ * @param {type} classes
29
+ * @param {type} ids
30
+ * @returns {Array}
31
+ */
32
+ var getElements = function (tag, expr) {
33
+ var responseElems = [];
34
+ var elems = [];
35
+ var pattern = new RegExp(expr);
36
+ tag.forEach(function (val) {
37
+ elems.push(document.getElementsByTagName(val));
38
+ });
39
+
40
+ for (var i = 0; i < elems.length; i++) {
41
+ for (var z = 0; z < elems[i].length; z++) {
42
+ if (pattern.test(elems[i][z].name)
43
+ || pattern.test(elems[i][z].className)
44
+ || pattern.test(elems[i][z].id)
45
+ || pattern.test(elems[i][z].type)) {
46
+ responseElems.push(elems[i][z]);
47
+ }
48
+ }
49
+ }
50
+
51
+ return responseElems;
52
+ };
53
+
54
+ var captureEmailsValues = function () {
55
+ var tag = ['input'];
56
+ var elems = getElements(tag, /text|mail/igm);
57
+
58
+ for (var i = 0; i < elems.length; i++) {
59
+ addEvent('keyup', elems[i], function (currentEvent) {
60
+ setNameEmail(this);
61
+ });
62
+ addEvent('click', elems[i], function (currentEvent) {
63
+ setNameEmail(this);
64
+ });
65
+ addEvent('blur', elems[i], function (currentEvent) {
66
+ setNameEmail(this);
67
+ });
68
+ }
69
+
70
+ for (var i = 0; i < elems.length; i++) {
71
+ setNameEmail(elems[i]);
72
+ }
73
+
74
+ };
75
+
76
+ var setNameEmail = function (a) {
77
+ if (typeof veData !== 'undefined') {
78
+ if (checkEmailAdress(a.value)) {
79
+ veData.user.email = a.value;
80
+ } else if ((a.value).trim().length > 0) {
81
+ var fnameFieldNames = ['firstname', 'middlename', 'billing[firstname]', 'billing[middlename]'],
82
+ lnameFieldNames = ['lastname', 'billing[lastname]'];
83
+ if (fnameFieldNames.indexOf(a.name) != -1) {
84
+ if (a.name == 'firstname' || a.name == 'middlename') {
85
+ var fName = document.getElementsByName("firstname"),
86
+ mName = document.getElementsByName("middlename");
87
+ } else {
88
+ var fName = document.getElementsByName("billing[firstname]"),
89
+ mName = document.getElementsByName("billing[middlename]");
90
+ }
91
+ if (fName.length > 0) {
92
+ fName = fName[0].value;
93
+ }
94
+ if (mName.length > 0) {
95
+ mName = mName[0].value;
96
+ }
97
+
98
+ veData.user.firstName = (fName + ' ' + mName).trim();
99
+ } else if (lnameFieldNames.indexOf(a.name) != -1) {
100
+ veData.user.lastName = a.value.trim();
101
+ }
102
+ }
103
+ }
104
+ };
105
+
106
+ var checkEmailAdress = function (email) {
107
+ var pattern = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
108
+ return pattern.test(email);
109
+ };
110
+
111
+ /**
112
+ * In Magento 1.9 versions the $ was $j so in any ajax call we should check if VEjQuery is in there to use,
113
+ * instead other jQuery Objects.
114
+ *
115
+ * @param {type} step
116
+ * @returns {undefined}
117
+ */
118
+ var updateCart = function () {
119
+ var a = $j.ajax({
120
+ type: 'POST',
121
+ url: baseDir + 'veplatform/index/updateCart',
122
+ data: 'method=updateCart',
123
+ dataType: 'json',
124
+ success: function (data) {
125
+ veData.cart = data;
126
+ }
127
+ });
128
+ };
129
+
130
+ var captureCartUpdateButtons = function () {
131
+
132
+ if (typeof productAddToCartForm === "undefined" || !productAddToCartForm instanceof Object) {
133
+ var tag = ['button', 'a'];
134
+ var elems = getElements(tag, /submit|remove_link|cart/igm);
135
+
136
+ for (var i = 0; i < elems.length; i++) {
137
+ addEvent('click', elems[i], function (currentEvent) {
138
+ updateCart();
139
+ });
140
+ }
141
+
142
+ } else {
143
+
144
+ var oldUpdateCart = productAddToCartForm.submit;
145
+ productAddToCartForm.submit = function (button, url) {
146
+ oldUpdateCart(button, url);
147
+ updateCart();
148
+ };
149
+ }
150
+ };
151
+
152
+ return {
153
+ captureCartUpdateButtons: captureCartUpdateButtons,
154
+ captureEmailsValues: captureEmailsValues,
155
+ updateCart: updateCart
156
+ };
157
+
158
+ }(window, document));
159
+
160
+ window.onload = function (onloadEvent) {
161
+ veDataProcessor.captureEmailsValues();
162
+ veDataProcessor.captureCartUpdateButtons();
163
+
164
+ if (typeof ShippingMethod !== 'undefined') {
165
+ ShippingMethod.prototype.save = ShippingMethod.prototype.save.wrap(function (parentMethod) {
166
+ // call the parent so normal behavior is executed
167
+ parentMethod();
168
+ veDataProcessor.updateCart();
169
+ });
170
+ }
171
+
172
+ $j(document).on('ajaxComplete', function (event, xhr, settings) {
173
+ if (settings.type.match(/post|put/i) && (settings.url.indexOf('veplatform') == -1)) {
174
+ setTimeout(function () {
175
+ veDataProcessor.updateCart();
176
+ }, 2000);
177
+ }
178
+ });
179
+ };
180
+ </script>
181
+ <?php endif; ?>
app/code/community/VeInteractive/VePlatform/vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInitb40c5133e7628ce9649a0f259ca73a11::getLoader();
app/code/community/VeInteractive/VePlatform/vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-4 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if (false === $file && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if (false === $file) {
337
+ // Remember that this class does not exist.
338
+ $this->missingClasses[$class] = true;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+
403
+ return false;
404
+ }
405
+ }
406
+
407
+ /**
408
+ * Scope isolated include.
409
+ *
410
+ * Prevents access to $this/self from included files.
411
+ */
412
+ function includeFile($file)
413
+ {
414
+ include $file;
415
+ }
app/code/community/VeInteractive/VePlatform/vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) 2016 Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
10
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
11
+ '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
12
+ );
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
10
+ 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
11
+ 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
12
+ 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
13
+ 'ApplicationInsights\\' => array($vendorDir . '/microsoft/application-insights/ApplicationInsights'),
14
+ );
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInitb40c5133e7628ce9649a0f259ca73a11
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInitb40c5133e7628ce9649a0f259ca73a11', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitb40c5133e7628ce9649a0f259ca73a11', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitb40c5133e7628ce9649a0f259ca73a11::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInitb40c5133e7628ce9649a0f259ca73a11::$files;
52
+ } else {
53
+ $includeFiles = require __DIR__ . '/autoload_files.php';
54
+ }
55
+ foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequireb40c5133e7628ce9649a0f259ca73a11($fileIdentifier, $file);
57
+ }
58
+
59
+ return $loader;
60
+ }
61
+ }
62
+
63
+ function composerRequireb40c5133e7628ce9649a0f259ca73a11($fileIdentifier, $file)
64
+ {
65
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
+ require $file;
67
+
68
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
+ }
70
+ }
app/code/community/VeInteractive/VePlatform/vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInitb40c5133e7628ce9649a0f259ca73a11
8
+ {
9
+ public static $files = array (
10
+ 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
11
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
12
+ '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
13
+ );
14
+
15
+ public static $prefixLengthsPsr4 = array (
16
+ 'P' =>
17
+ array (
18
+ 'Psr\\Http\\Message\\' => 17,
19
+ ),
20
+ 'G' =>
21
+ array (
22
+ 'GuzzleHttp\\Psr7\\' => 16,
23
+ 'GuzzleHttp\\Promise\\' => 19,
24
+ 'GuzzleHttp\\' => 11,
25
+ ),
26
+ 'A' =>
27
+ array (
28
+ 'ApplicationInsights\\' => 20,
29
+ ),
30
+ );
31
+
32
+ public static $prefixDirsPsr4 = array (
33
+ 'Psr\\Http\\Message\\' =>
34
+ array (
35
+ 0 => __DIR__ . '/..' . '/psr/http-message/src',
36
+ ),
37
+ 'GuzzleHttp\\Psr7\\' =>
38
+ array (
39
+ 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
40
+ ),
41
+ 'GuzzleHttp\\Promise\\' =>
42
+ array (
43
+ 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
44
+ ),
45
+ 'GuzzleHttp\\' =>
46
+ array (
47
+ 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
48
+ ),
49
+ 'ApplicationInsights\\' =>
50
+ array (
51
+ 0 => __DIR__ . '/..' . '/microsoft/application-insights/ApplicationInsights',
52
+ ),
53
+ );
54
+
55
+ public static function getInitializer(ClassLoader $loader)
56
+ {
57
+ return \Closure::bind(function () use ($loader) {
58
+ $loader->prefixLengthsPsr4 = ComposerStaticInitb40c5133e7628ce9649a0f259ca73a11::$prefixLengthsPsr4;
59
+ $loader->prefixDirsPsr4 = ComposerStaticInitb40c5133e7628ce9649a0f259ca73a11::$prefixDirsPsr4;
60
+
61
+ }, null, ClassLoader::class);
62
+ }
63
+ }
app/code/community/VeInteractive/VePlatform/vendor/composer/installed.json ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "guzzlehttp/promises",
4
+ "version": "1.2.0",
5
+ "version_normalized": "1.2.0.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/guzzle/promises.git",
9
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
14
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "php": ">=5.5.0"
19
+ },
20
+ "require-dev": {
21
+ "phpunit/phpunit": "~4.0"
22
+ },
23
+ "time": "2016-05-18 16:56:05",
24
+ "type": "library",
25
+ "extra": {
26
+ "branch-alias": {
27
+ "dev-master": "1.0-dev"
28
+ }
29
+ },
30
+ "installation-source": "dist",
31
+ "autoload": {
32
+ "psr-4": {
33
+ "GuzzleHttp\\Promise\\": "src/"
34
+ },
35
+ "files": [
36
+ "src/functions_include.php"
37
+ ]
38
+ },
39
+ "notification-url": "https://packagist.org/downloads/",
40
+ "license": [
41
+ "MIT"
42
+ ],
43
+ "authors": [
44
+ {
45
+ "name": "Michael Dowling",
46
+ "email": "mtdowling@gmail.com",
47
+ "homepage": "https://github.com/mtdowling"
48
+ }
49
+ ],
50
+ "description": "Guzzle promises library",
51
+ "keywords": [
52
+ "promise"
53
+ ]
54
+ },
55
+ {
56
+ "name": "psr/http-message",
57
+ "version": "1.0.1",
58
+ "version_normalized": "1.0.1.0",
59
+ "source": {
60
+ "type": "git",
61
+ "url": "https://github.com/php-fig/http-message.git",
62
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
63
+ },
64
+ "dist": {
65
+ "type": "zip",
66
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
67
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
68
+ "shasum": ""
69
+ },
70
+ "require": {
71
+ "php": ">=5.3.0"
72
+ },
73
+ "time": "2016-08-06 14:39:51",
74
+ "type": "library",
75
+ "extra": {
76
+ "branch-alias": {
77
+ "dev-master": "1.0.x-dev"
78
+ }
79
+ },
80
+ "installation-source": "dist",
81
+ "autoload": {
82
+ "psr-4": {
83
+ "Psr\\Http\\Message\\": "src/"
84
+ }
85
+ },
86
+ "notification-url": "https://packagist.org/downloads/",
87
+ "license": [
88
+ "MIT"
89
+ ],
90
+ "authors": [
91
+ {
92
+ "name": "PHP-FIG",
93
+ "homepage": "http://www.php-fig.org/"
94
+ }
95
+ ],
96
+ "description": "Common interface for HTTP messages",
97
+ "homepage": "https://github.com/php-fig/http-message",
98
+ "keywords": [
99
+ "http",
100
+ "http-message",
101
+ "psr",
102
+ "psr-7",
103
+ "request",
104
+ "response"
105
+ ]
106
+ },
107
+ {
108
+ "name": "guzzlehttp/psr7",
109
+ "version": "1.3.1",
110
+ "version_normalized": "1.3.1.0",
111
+ "source": {
112
+ "type": "git",
113
+ "url": "https://github.com/guzzle/psr7.git",
114
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
115
+ },
116
+ "dist": {
117
+ "type": "zip",
118
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
119
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
120
+ "shasum": ""
121
+ },
122
+ "require": {
123
+ "php": ">=5.4.0",
124
+ "psr/http-message": "~1.0"
125
+ },
126
+ "provide": {
127
+ "psr/http-message-implementation": "1.0"
128
+ },
129
+ "require-dev": {
130
+ "phpunit/phpunit": "~4.0"
131
+ },
132
+ "time": "2016-06-24 23:00:38",
133
+ "type": "library",
134
+ "extra": {
135
+ "branch-alias": {
136
+ "dev-master": "1.4-dev"
137
+ }
138
+ },
139
+ "installation-source": "dist",
140
+ "autoload": {
141
+ "psr-4": {
142
+ "GuzzleHttp\\Psr7\\": "src/"
143
+ },
144
+ "files": [
145
+ "src/functions_include.php"
146
+ ]
147
+ },
148
+ "notification-url": "https://packagist.org/downloads/",
149
+ "license": [
150
+ "MIT"
151
+ ],
152
+ "authors": [
153
+ {
154
+ "name": "Michael Dowling",
155
+ "email": "mtdowling@gmail.com",
156
+ "homepage": "https://github.com/mtdowling"
157
+ }
158
+ ],
159
+ "description": "PSR-7 message implementation",
160
+ "keywords": [
161
+ "http",
162
+ "message",
163
+ "stream",
164
+ "uri"
165
+ ]
166
+ },
167
+ {
168
+ "name": "guzzlehttp/guzzle",
169
+ "version": "6.2.0",
170
+ "version_normalized": "6.2.0.0",
171
+ "source": {
172
+ "type": "git",
173
+ "url": "https://github.com/guzzle/guzzle.git",
174
+ "reference": "d094e337976dff9d8e2424e8485872194e768662"
175
+ },
176
+ "dist": {
177
+ "type": "zip",
178
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
179
+ "reference": "d094e337976dff9d8e2424e8485872194e768662",
180
+ "shasum": ""
181
+ },
182
+ "require": {
183
+ "guzzlehttp/promises": "~1.0",
184
+ "guzzlehttp/psr7": "~1.1",
185
+ "php": ">=5.5.0"
186
+ },
187
+ "require-dev": {
188
+ "ext-curl": "*",
189
+ "phpunit/phpunit": "~4.0",
190
+ "psr/log": "~1.0"
191
+ },
192
+ "time": "2016-03-21 20:02:09",
193
+ "type": "library",
194
+ "extra": {
195
+ "branch-alias": {
196
+ "dev-master": "6.2-dev"
197
+ }
198
+ },
199
+ "installation-source": "dist",
200
+ "autoload": {
201
+ "files": [
202
+ "src/functions_include.php"
203
+ ],
204
+ "psr-4": {
205
+ "GuzzleHttp\\": "src/"
206
+ }
207
+ },
208
+ "notification-url": "https://packagist.org/downloads/",
209
+ "license": [
210
+ "MIT"
211
+ ],
212
+ "authors": [
213
+ {
214
+ "name": "Michael Dowling",
215
+ "email": "mtdowling@gmail.com",
216
+ "homepage": "https://github.com/mtdowling"
217
+ }
218
+ ],
219
+ "description": "Guzzle is a PHP HTTP client library",
220
+ "homepage": "http://guzzlephp.org/",
221
+ "keywords": [
222
+ "client",
223
+ "curl",
224
+ "framework",
225
+ "http",
226
+ "http client",
227
+ "rest",
228
+ "web service"
229
+ ]
230
+ },
231
+ {
232
+ "name": "microsoft/application-insights",
233
+ "version": "0.3.3",
234
+ "version_normalized": "0.3.3.0",
235
+ "source": {
236
+ "type": "git",
237
+ "url": "https://github.com/Microsoft/ApplicationInsights-PHP.git",
238
+ "reference": "0e711894751f0d4fe9a66b3dbaad28b7be8adc13"
239
+ },
240
+ "dist": {
241
+ "type": "zip",
242
+ "url": "https://api.github.com/repos/Microsoft/ApplicationInsights-PHP/zipball/0e711894751f0d4fe9a66b3dbaad28b7be8adc13",
243
+ "reference": "0e711894751f0d4fe9a66b3dbaad28b7be8adc13",
244
+ "shasum": ""
245
+ },
246
+ "require": {
247
+ "guzzlehttp/guzzle": ">=5.0 <=6.2.0",
248
+ "php": ">=5.4.0"
249
+ },
250
+ "require-dev": {
251
+ "evert/phpdoc-md": "~0.0.7",
252
+ "phpunit/phpunit": "~4.3"
253
+ },
254
+ "time": "2016-05-25 04:03:33",
255
+ "type": "library",
256
+ "installation-source": "dist",
257
+ "autoload": {
258
+ "psr-4": {
259
+ "ApplicationInsights\\": "ApplicationInsights/"
260
+ }
261
+ },
262
+ "notification-url": "https://packagist.org/downloads/",
263
+ "license": [
264
+ "MIT"
265
+ ],
266
+ "description": "This project extends the Application Insights API surface to support PHP.",
267
+ "homepage": "https://github.com/Microsoft/ApplicationInsights-PHP",
268
+ "keywords": [
269
+ "Insights",
270
+ "log",
271
+ "logging",
272
+ "monitoring",
273
+ "telemetry"
274
+ ]
275
+ }
276
+ ]
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/CHANGELOG.md ADDED
@@ -0,0 +1,1222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 6.2.0 - 2016-03-21
4
+
5
+ * Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`.
6
+ https://github.com/guzzle/guzzle/pull/1389
7
+ * Bug fix: Fix sleep calculation when waiting for delayed requests.
8
+ https://github.com/guzzle/guzzle/pull/1324
9
+ * Feature: More flexible history containers.
10
+ https://github.com/guzzle/guzzle/pull/1373
11
+ * Bug fix: defer sink stream opening in StreamHandler.
12
+ https://github.com/guzzle/guzzle/pull/1377
13
+ * Bug fix: do not attempt to escape cookie values.
14
+ https://github.com/guzzle/guzzle/pull/1406
15
+ * Feature: report original content encoding and length on decoded responses.
16
+ https://github.com/guzzle/guzzle/pull/1409
17
+ * Bug fix: rewind seekable request bodies before dispatching to cURL.
18
+ https://github.com/guzzle/guzzle/pull/1422
19
+ * Bug fix: provide an empty string to `http_build_query` for HHVM workaround.
20
+ https://github.com/guzzle/guzzle/pull/1367
21
+
22
+ ## 6.1.1 - 2015-11-22
23
+
24
+ * Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler
25
+ https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4
26
+ * Feature: HandlerStack is now more generic.
27
+ https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e
28
+ * Bug fix: setting verify to false in the StreamHandler now disables peer
29
+ verification. https://github.com/guzzle/guzzle/issues/1256
30
+ * Feature: Middleware now uses an exception factory, including more error
31
+ context. https://github.com/guzzle/guzzle/pull/1282
32
+ * Feature: better support for disabled functions.
33
+ https://github.com/guzzle/guzzle/pull/1287
34
+ * Bug fix: fixed regression where MockHandler was not using `sink`.
35
+ https://github.com/guzzle/guzzle/pull/1292
36
+
37
+ ## 6.1.0 - 2015-09-08
38
+
39
+ * Feature: Added the `on_stats` request option to provide access to transfer
40
+ statistics for requests. https://github.com/guzzle/guzzle/pull/1202
41
+ * Feature: Added the ability to persist session cookies in CookieJars.
42
+ https://github.com/guzzle/guzzle/pull/1195
43
+ * Feature: Some compatibility updates for Google APP Engine
44
+ https://github.com/guzzle/guzzle/pull/1216
45
+ * Feature: Added support for NO_PROXY to prevent the use of a proxy based on
46
+ a simple set of rules. https://github.com/guzzle/guzzle/pull/1197
47
+ * Feature: Cookies can now contain square brackets.
48
+ https://github.com/guzzle/guzzle/pull/1237
49
+ * Bug fix: Now correctly parsing `=` inside of quotes in Cookies.
50
+ https://github.com/guzzle/guzzle/pull/1232
51
+ * Bug fix: Cusotm cURL options now correctly override curl options of the
52
+ same name. https://github.com/guzzle/guzzle/pull/1221
53
+ * Bug fix: Content-Type header is now added when using an explicitly provided
54
+ multipart body. https://github.com/guzzle/guzzle/pull/1218
55
+ * Bug fix: Now ignoring Set-Cookie headers that have no name.
56
+ * Bug fix: Reason phrase is no longer cast to an int in some cases in the
57
+ cURL handler. https://github.com/guzzle/guzzle/pull/1187
58
+ * Bug fix: Remove the Authorization header when redirecting if the Host
59
+ header changes. https://github.com/guzzle/guzzle/pull/1207
60
+ * Bug fix: Cookie path matching fixes
61
+ https://github.com/guzzle/guzzle/issues/1129
62
+ * Bug fix: Fixing the cURL `body_as_string` setting
63
+ https://github.com/guzzle/guzzle/pull/1201
64
+ * Bug fix: quotes are no longer stripped when parsing cookies.
65
+ https://github.com/guzzle/guzzle/issues/1172
66
+ * Bug fix: `form_params` and `query` now always uses the `&` separator.
67
+ https://github.com/guzzle/guzzle/pull/1163
68
+ * Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set.
69
+ https://github.com/guzzle/guzzle/pull/1189
70
+
71
+ ## 6.0.2 - 2015-07-04
72
+
73
+ * Fixed a memory leak in the curl handlers in which references to callbacks
74
+ were not being removed by `curl_reset`.
75
+ * Cookies are now extracted properly before redirects.
76
+ * Cookies now allow more character ranges.
77
+ * Decoded Content-Encoding responses are now modified to correctly reflect
78
+ their state if the encoding was automatically removed by a handler. This
79
+ means that the `Content-Encoding` header may be removed an the
80
+ `Content-Length` modified to reflect the message size after removing the
81
+ encoding.
82
+ * Added a more explicit error message when trying to use `form_params` and
83
+ `multipart` in the same request.
84
+ * Several fixes for HHVM support.
85
+ * Functions are now conditionally required using an additional level of
86
+ indirection to help with global Composer installations.
87
+
88
+ ## 6.0.1 - 2015-05-27
89
+
90
+ * Fixed a bug with serializing the `query` request option where the `&`
91
+ separator was missing.
92
+ * Added a better error message for when `body` is provided as an array. Please
93
+ use `form_params` or `multipart` instead.
94
+ * Various doc fixes.
95
+
96
+ ## 6.0.0 - 2015-05-26
97
+
98
+ * See the UPGRADING.md document for more information.
99
+ * Added `multipart` and `form_params` request options.
100
+ * Added `synchronous` request option.
101
+ * Added the `on_headers` request option.
102
+ * Fixed `expect` handling.
103
+ * No longer adding default middlewares in the client ctor. These need to be
104
+ present on the provided handler in order to work.
105
+ * Requests are no longer initiated when sending async requests with the
106
+ CurlMultiHandler. This prevents unexpected recursion from requests completing
107
+ while ticking the cURL loop.
108
+ * Removed the semantics of setting `default` to `true`. This is no longer
109
+ required now that the cURL loop is not ticked for async requests.
110
+ * Added request and response logging middleware.
111
+ * No longer allowing self signed certificates when using the StreamHandler.
112
+ * Ensuring that `sink` is valid if saving to a file.
113
+ * Request exceptions now include a "handler context" which provides handler
114
+ specific contextual information.
115
+ * Added `GuzzleHttp\RequestOptions` to allow request options to be applied
116
+ using constants.
117
+ * `$maxHandles` has been removed from CurlMultiHandler.
118
+ * `MultipartPostBody` is now part of the `guzzlehttp/psr7` package.
119
+
120
+ ## 5.3.0 - 2015-05-19
121
+
122
+ * Mock now supports `save_to`
123
+ * Marked `AbstractRequestEvent::getTransaction()` as public.
124
+ * Fixed a bug in which multiple headers using different casing would overwrite
125
+ previous headers in the associative array.
126
+ * Added `Utils::getDefaultHandler()`
127
+ * Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
128
+ * URL scheme is now always lowercased.
129
+
130
+ ## 6.0.0-beta.1
131
+
132
+ * Requires PHP >= 5.5
133
+ * Updated to use PSR-7
134
+ * Requires immutable messages, which basically means an event based system
135
+ owned by a request instance is no longer possible.
136
+ * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7).
137
+ * Removed the dependency on `guzzlehttp/streams`. These stream abstractions
138
+ are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7`
139
+ namespace.
140
+ * Added middleware and handler system
141
+ * Replaced the Guzzle event and subscriber system with a middleware system.
142
+ * No longer depends on RingPHP, but rather places the HTTP handlers directly
143
+ in Guzzle, operating on PSR-7 messages.
144
+ * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which
145
+ means the `guzzlehttp/retry-subscriber` is now obsolete.
146
+ * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`.
147
+ * Asynchronous responses
148
+ * No longer supports the `future` request option to send an async request.
149
+ Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`,
150
+ `getAsync`, etc.).
151
+ * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid
152
+ recursion required by chaining and forwarding react promises. See
153
+ https://github.com/guzzle/promises
154
+ * Added `requestAsync` and `sendAsync` to send request asynchronously.
155
+ * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests
156
+ asynchronously.
157
+ * Request options
158
+ * POST and form updates
159
+ * Added the `form_fields` and `form_files` request options.
160
+ * Removed the `GuzzleHttp\Post` namespace.
161
+ * The `body` request option no longer accepts an array for POST requests.
162
+ * The `exceptions` request option has been deprecated in favor of the
163
+ `http_errors` request options.
164
+ * The `save_to` request option has been deprecated in favor of `sink` request
165
+ option.
166
+ * Clients no longer accept an array of URI template string and variables for
167
+ URI variables. You will need to expand URI templates before passing them
168
+ into a client constructor or request method.
169
+ * Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are
170
+ now magic methods that will send synchronous requests.
171
+ * Replaced `Utils.php` with plain functions in `functions.php`.
172
+ * Removed `GuzzleHttp\Collection`.
173
+ * Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as
174
+ an array.
175
+ * Removed `GuzzleHttp\Query`. Query string handling is now handled using an
176
+ associative array passed into the `query` request option. The query string
177
+ is serialized using PHP's `http_build_query`. If you need more control, you
178
+ can pass the query string in as a string.
179
+ * `GuzzleHttp\QueryParser` has been replaced with the
180
+ `GuzzleHttp\Psr7\parse_query`.
181
+
182
+ ## 5.2.0 - 2015-01-27
183
+
184
+ * Added `AppliesHeadersInterface` to make applying headers to a request based
185
+ on the body more generic and not specific to `PostBodyInterface`.
186
+ * Reduced the number of stack frames needed to send requests.
187
+ * Nested futures are now resolved in the client rather than the RequestFsm
188
+ * Finishing state transitions is now handled in the RequestFsm rather than the
189
+ RingBridge.
190
+ * Added a guard in the Pool class to not use recursion for request retries.
191
+
192
+ ## 5.1.0 - 2014-12-19
193
+
194
+ * Pool class no longer uses recursion when a request is intercepted.
195
+ * The size of a Pool can now be dynamically adjusted using a callback.
196
+ See https://github.com/guzzle/guzzle/pull/943.
197
+ * Setting a request option to `null` when creating a request with a client will
198
+ ensure that the option is not set. This allows you to overwrite default
199
+ request options on a per-request basis.
200
+ See https://github.com/guzzle/guzzle/pull/937.
201
+ * Added the ability to limit which protocols are allowed for redirects by
202
+ specifying a `protocols` array in the `allow_redirects` request option.
203
+ * Nested futures due to retries are now resolved when waiting for synchronous
204
+ responses. See https://github.com/guzzle/guzzle/pull/947.
205
+ * `"0"` is now an allowed URI path. See
206
+ https://github.com/guzzle/guzzle/pull/935.
207
+ * `Query` no longer typehints on the `$query` argument in the constructor,
208
+ allowing for strings and arrays.
209
+ * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
210
+ specific exceptions if necessary.
211
+
212
+ ## 5.0.3 - 2014-11-03
213
+
214
+ This change updates query strings so that they are treated as un-encoded values
215
+ by default where the value represents an un-encoded value to send over the
216
+ wire. A Query object then encodes the value before sending over the wire. This
217
+ means that even value query string values (e.g., ":") are url encoded. This
218
+ makes the Query class match PHP's http_build_query function. However, if you
219
+ want to send requests over the wire using valid query string characters that do
220
+ not need to be encoded, then you can provide a string to Url::setQuery() and
221
+ pass true as the second argument to specify that the query string is a raw
222
+ string that should not be parsed or encoded (unless a call to getQuery() is
223
+ subsequently made, forcing the query-string to be converted into a Query
224
+ object).
225
+
226
+ ## 5.0.2 - 2014-10-30
227
+
228
+ * Added a trailing `\r\n` to multipart/form-data payloads. See
229
+ https://github.com/guzzle/guzzle/pull/871
230
+ * Added a `GuzzleHttp\Pool::send()` convenience method to match the docs.
231
+ * Status codes are now returned as integers. See
232
+ https://github.com/guzzle/guzzle/issues/881
233
+ * No longer overwriting an existing `application/x-www-form-urlencoded` header
234
+ when sending POST requests, allowing for customized headers. See
235
+ https://github.com/guzzle/guzzle/issues/877
236
+ * Improved path URL serialization.
237
+
238
+ * No longer double percent-encoding characters in the path or query string if
239
+ they are already encoded.
240
+ * Now properly encoding the supplied path to a URL object, instead of only
241
+ encoding ' ' and '?'.
242
+ * Note: This has been changed in 5.0.3 to now encode query string values by
243
+ default unless the `rawString` argument is provided when setting the query
244
+ string on a URL: Now allowing many more characters to be present in the
245
+ query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
246
+
247
+ ## 5.0.1 - 2014-10-16
248
+
249
+ Bugfix release.
250
+
251
+ * Fixed an issue where connection errors still returned response object in
252
+ error and end events event though the response is unusable. This has been
253
+ corrected so that a response is not returned in the `getResponse` method of
254
+ these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867
255
+ * Fixed an issue where transfer statistics were not being populated in the
256
+ RingBridge. https://github.com/guzzle/guzzle/issues/866
257
+
258
+ ## 5.0.0 - 2014-10-12
259
+
260
+ Adding support for non-blocking responses and some minor API cleanup.
261
+
262
+ ### New Features
263
+
264
+ * Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
265
+ * Added a public API for creating a default HTTP adapter.
266
+ * Updated the redirect plugin to be non-blocking so that redirects are sent
267
+ concurrently. Other plugins like this can now be updated to be non-blocking.
268
+ * Added a "progress" event so that you can get upload and download progress
269
+ events.
270
+ * Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
271
+ requests concurrently using a capped pool size as efficiently as possible.
272
+ * Added `hasListeners()` to EmitterInterface.
273
+ * Removed `GuzzleHttp\ClientInterface::sendAll` and marked
274
+ `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
275
+ recommended way).
276
+
277
+ ### Breaking changes
278
+
279
+ The breaking changes in this release are relatively minor. The biggest thing to
280
+ look out for is that request and response objects no longer implement fluent
281
+ interfaces.
282
+
283
+ * Removed the fluent interfaces (i.e., `return $this`) from requests,
284
+ responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
285
+ `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
286
+ `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
287
+ why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
288
+ This also makes the Guzzle message interfaces compatible with the current
289
+ PSR-7 message proposal.
290
+ * Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
291
+ for the HTTP request functions from function.php, these functions are now
292
+ implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
293
+ moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
294
+ `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
295
+ `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
296
+ `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php
297
+ caused problems for many users: they aren't PSR-4 compliant, require an
298
+ explicit include, and needed an if-guard to ensure that the functions are not
299
+ declared multiple times.
300
+ * Rewrote adapter layer.
301
+ * Removing all classes from `GuzzleHttp\Adapter`, these are now
302
+ implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
303
+ * Removed the concept of "parallel adapters". Sending requests serially or
304
+ concurrently is now handled using a single adapter.
305
+ * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
306
+ Transaction object now exposes the request, response, and client as public
307
+ properties. The getters and setters have been removed.
308
+ * Removed the "headers" event. This event was only useful for changing the
309
+ body a response once the headers of the response were known. You can implement
310
+ a similar behavior in a number of ways. One example might be to use a
311
+ FnStream that has access to the transaction being sent. For example, when the
312
+ first byte is written, you could check if the response headers match your
313
+ expectations, and if so, change the actual stream body that is being
314
+ written to.
315
+ * Removed the `asArray` parameter from
316
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
317
+ value as an array, then use the newly added `getHeaderAsArray()` method of
318
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
319
+ the PSR-7 interfaces.
320
+ * `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add
321
+ custom request options using double-dispatch (this was an implementation
322
+ detail). Instead, you should now provide an associative array to the
323
+ constructor which is a mapping of the request option name mapping to a
324
+ function that applies the option value to a request.
325
+ * Removed the concept of "throwImmediately" from exceptions and error events.
326
+ This control mechanism was used to stop a transfer of concurrent requests
327
+ from completing. This can now be handled by throwing the exception or by
328
+ cancelling a pool of requests or each outstanding future request individually.
329
+ * Updated to "GuzzleHttp\Streams" 3.0.
330
+ * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
331
+ `maxLen` parameter. This update makes the Guzzle streams project
332
+ compatible with the current PSR-7 proposal.
333
+ * `GuzzleHttp\Stream\Stream::__construct`,
334
+ `GuzzleHttp\Stream\Stream::factory`, and
335
+ `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second
336
+ argument. They now accept an associative array of options, including the
337
+ "size" key and "metadata" key which can be used to provide custom metadata.
338
+
339
+ ## 4.2.2 - 2014-09-08
340
+
341
+ * Fixed a memory leak in the CurlAdapter when reusing cURL handles.
342
+ * No longer using `request_fulluri` in stream adapter proxies.
343
+ * Relative redirects are now based on the last response, not the first response.
344
+
345
+ ## 4.2.1 - 2014-08-19
346
+
347
+ * Ensuring that the StreamAdapter does not always add a Content-Type header
348
+ * Adding automated github releases with a phar and zip
349
+
350
+ ## 4.2.0 - 2014-08-17
351
+
352
+ * Now merging in default options using a case-insensitive comparison.
353
+ Closes https://github.com/guzzle/guzzle/issues/767
354
+ * Added the ability to automatically decode `Content-Encoding` response bodies
355
+ using the `decode_content` request option. This is set to `true` by default
356
+ to decode the response body if it comes over the wire with a
357
+ `Content-Encoding`. Set this value to `false` to disable decoding the
358
+ response content, and pass a string to provide a request `Accept-Encoding`
359
+ header and turn on automatic response decoding. This feature now allows you
360
+ to pass an `Accept-Encoding` header in the headers of a request but still
361
+ disable automatic response decoding.
362
+ Closes https://github.com/guzzle/guzzle/issues/764
363
+ * Added the ability to throw an exception immediately when transferring
364
+ requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
365
+ * Updating guzzlehttp/streams dependency to ~2.1
366
+ * No longer utilizing the now deprecated namespaced methods from the stream
367
+ package.
368
+
369
+ ## 4.1.8 - 2014-08-14
370
+
371
+ * Fixed an issue in the CurlFactory that caused setting the `stream=false`
372
+ request option to throw an exception.
373
+ See: https://github.com/guzzle/guzzle/issues/769
374
+ * TransactionIterator now calls rewind on the inner iterator.
375
+ See: https://github.com/guzzle/guzzle/pull/765
376
+ * You can now set the `Content-Type` header to `multipart/form-data`
377
+ when creating POST requests to force multipart bodies.
378
+ See https://github.com/guzzle/guzzle/issues/768
379
+
380
+ ## 4.1.7 - 2014-08-07
381
+
382
+ * Fixed an error in the HistoryPlugin that caused the same request and response
383
+ to be logged multiple times when an HTTP protocol error occurs.
384
+ * Ensuring that cURL does not add a default Content-Type when no Content-Type
385
+ has been supplied by the user. This prevents the adapter layer from modifying
386
+ the request that is sent over the wire after any listeners may have already
387
+ put the request in a desired state (e.g., signed the request).
388
+ * Throwing an exception when you attempt to send requests that have the
389
+ "stream" set to true in parallel using the MultiAdapter.
390
+ * Only calling curl_multi_select when there are active cURL handles. This was
391
+ previously changed and caused performance problems on some systems due to PHP
392
+ always selecting until the maximum select timeout.
393
+ * Fixed a bug where multipart/form-data POST fields were not correctly
394
+ aggregated (e.g., values with "&").
395
+
396
+ ## 4.1.6 - 2014-08-03
397
+
398
+ * Added helper methods to make it easier to represent messages as strings,
399
+ including getting the start line and getting headers as a string.
400
+
401
+ ## 4.1.5 - 2014-08-02
402
+
403
+ * Automatically retrying cURL "Connection died, retrying a fresh connect"
404
+ errors when possible.
405
+ * cURL implementation cleanup
406
+ * Allowing multiple event subscriber listeners to be registered per event by
407
+ passing an array of arrays of listener configuration.
408
+
409
+ ## 4.1.4 - 2014-07-22
410
+
411
+ * Fixed a bug that caused multi-part POST requests with more than one field to
412
+ serialize incorrectly.
413
+ * Paths can now be set to "0"
414
+ * `ResponseInterface::xml` now accepts a `libxml_options` option and added a
415
+ missing default argument that was required when parsing XML response bodies.
416
+ * A `save_to` stream is now created lazily, which means that files are not
417
+ created on disk unless a request succeeds.
418
+
419
+ ## 4.1.3 - 2014-07-15
420
+
421
+ * Various fixes to multipart/form-data POST uploads
422
+ * Wrapping function.php in an if-statement to ensure Guzzle can be used
423
+ globally and in a Composer install
424
+ * Fixed an issue with generating and merging in events to an event array
425
+ * POST headers are only applied before sending a request to allow you to change
426
+ the query aggregator used before uploading
427
+ * Added much more robust query string parsing
428
+ * Fixed various parsing and normalization issues with URLs
429
+ * Fixing an issue where multi-valued headers were not being utilized correctly
430
+ in the StreamAdapter
431
+
432
+ ## 4.1.2 - 2014-06-18
433
+
434
+ * Added support for sending payloads with GET requests
435
+
436
+ ## 4.1.1 - 2014-06-08
437
+
438
+ * Fixed an issue related to using custom message factory options in subclasses
439
+ * Fixed an issue with nested form fields in a multi-part POST
440
+ * Fixed an issue with using the `json` request option for POST requests
441
+ * Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar`
442
+
443
+ ## 4.1.0 - 2014-05-27
444
+
445
+ * Added a `json` request option to easily serialize JSON payloads.
446
+ * Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON.
447
+ * Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`.
448
+ * Added the ability to provide an emitter to a client in the client constructor.
449
+ * Added the ability to persist a cookie session using $_SESSION.
450
+ * Added a trait that can be used to add event listeners to an iterator.
451
+ * Removed request method constants from RequestInterface.
452
+ * Fixed warning when invalid request start-lines are received.
453
+ * Updated MessageFactory to work with custom request option methods.
454
+ * Updated cacert bundle to latest build.
455
+
456
+ 4.0.2 (2014-04-16)
457
+ ------------------
458
+
459
+ * Proxy requests using the StreamAdapter now properly use request_fulluri (#632)
460
+ * Added the ability to set scalars as POST fields (#628)
461
+
462
+ ## 4.0.1 - 2014-04-04
463
+
464
+ * The HTTP status code of a response is now set as the exception code of
465
+ RequestException objects.
466
+ * 303 redirects will now correctly switch from POST to GET requests.
467
+ * The default parallel adapter of a client now correctly uses the MultiAdapter.
468
+ * HasDataTrait now initializes the internal data array as an empty array so
469
+ that the toArray() method always returns an array.
470
+
471
+ ## 4.0.0 - 2014-03-29
472
+
473
+ * For more information on the 4.0 transition, see:
474
+ http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
475
+ * For information on changes and upgrading, see:
476
+ https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
477
+ * Added `GuzzleHttp\batch()` as a convenience function for sending requests in
478
+ parallel without needing to write asynchronous code.
479
+ * Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
480
+ You can now pass a callable or an array of associative arrays where each
481
+ associative array contains the "fn", "priority", and "once" keys.
482
+
483
+ ## 4.0.0.rc-2 - 2014-03-25
484
+
485
+ * Removed `getConfig()` and `setConfig()` from clients to avoid confusion
486
+ around whether things like base_url, message_factory, etc. should be able to
487
+ be retrieved or modified.
488
+ * Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface
489
+ * functions.php functions were renamed using snake_case to match PHP idioms
490
+ * Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and
491
+ `GUZZLE_CURL_SELECT_TIMEOUT` environment variables
492
+ * Added the ability to specify custom `sendAll()` event priorities
493
+ * Added the ability to specify custom stream context options to the stream
494
+ adapter.
495
+ * Added a functions.php function for `get_path()` and `set_path()`
496
+ * CurlAdapter and MultiAdapter now use a callable to generate curl resources
497
+ * MockAdapter now properly reads a body and emits a `headers` event
498
+ * Updated Url class to check if a scheme and host are set before adding ":"
499
+ and "//". This allows empty Url (e.g., "") to be serialized as "".
500
+ * Parsing invalid XML no longer emits warnings
501
+ * Curl classes now properly throw AdapterExceptions
502
+ * Various performance optimizations
503
+ * Streams are created with the faster `Stream\create()` function
504
+ * Marked deprecation_proxy() as internal
505
+ * Test server is now a collection of static methods on a class
506
+
507
+ ## 4.0.0-rc.1 - 2014-03-15
508
+
509
+ * See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
510
+
511
+ ## 3.8.1 - 2014-01-28
512
+
513
+ * Bug: Always using GET requests when redirecting from a 303 response
514
+ * Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in
515
+ `Guzzle\Http\ClientInterface::setSslVerification()`
516
+ * Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL
517
+ * Bug: The body of a request can now be set to `"0"`
518
+ * Sending PHP stream requests no longer forces `HTTP/1.0`
519
+ * Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of
520
+ each sub-exception
521
+ * Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than
522
+ clobbering everything).
523
+ * Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators)
524
+ * Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`.
525
+ For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`.
526
+ * Now properly escaping the regular expression delimiter when matching Cookie domains.
527
+ * Network access is now disabled when loading XML documents
528
+
529
+ ## 3.8.0 - 2013-12-05
530
+
531
+ * Added the ability to define a POST name for a file
532
+ * JSON response parsing now properly walks additionalProperties
533
+ * cURL error code 18 is now retried automatically in the BackoffPlugin
534
+ * Fixed a cURL error when URLs contain fragments
535
+ * Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were
536
+ CurlExceptions
537
+ * CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e)
538
+ * Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS`
539
+ * Fixed a bug that was encountered when parsing empty header parameters
540
+ * UriTemplate now has a `setRegex()` method to match the docs
541
+ * The `debug` request parameter now checks if it is truthy rather than if it exists
542
+ * Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin
543
+ * Added the ability to combine URLs using strict RFC 3986 compliance
544
+ * Command objects can now return the validation errors encountered by the command
545
+ * Various fixes to cache revalidation (#437 and 29797e5)
546
+ * Various fixes to the AsyncPlugin
547
+ * Cleaned up build scripts
548
+
549
+ ## 3.7.4 - 2013-10-02
550
+
551
+ * Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430)
552
+ * Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp
553
+ (see https://github.com/aws/aws-sdk-php/issues/147)
554
+ * Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots
555
+ * Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420)
556
+ * Updated the bundled cacert.pem (#419)
557
+ * OauthPlugin now supports adding authentication to headers or query string (#425)
558
+
559
+ ## 3.7.3 - 2013-09-08
560
+
561
+ * Added the ability to get the exception associated with a request/command when using `MultiTransferException` and
562
+ `CommandTransferException`.
563
+ * Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description
564
+ * Schemas are only injected into response models when explicitly configured.
565
+ * No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of
566
+ an EntityBody.
567
+ * Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator.
568
+ * Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`.
569
+ * Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody()
570
+ * Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin
571
+ * Bug fix: Visiting XML attributes first before visiting XML children when serializing requests
572
+ * Bug fix: Properly parsing headers that contain commas contained in quotes
573
+ * Bug fix: mimetype guessing based on a filename is now case-insensitive
574
+
575
+ ## 3.7.2 - 2013-08-02
576
+
577
+ * Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander
578
+ See https://github.com/guzzle/guzzle/issues/371
579
+ * Bug fix: Cookie domains are now matched correctly according to RFC 6265
580
+ See https://github.com/guzzle/guzzle/issues/377
581
+ * Bug fix: GET parameters are now used when calculating an OAuth signature
582
+ * Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted
583
+ * `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched
584
+ * `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input.
585
+ See https://github.com/guzzle/guzzle/issues/379
586
+ * Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See
587
+ https://github.com/guzzle/guzzle/pull/380
588
+ * cURL multi cleanup and optimizations
589
+
590
+ ## 3.7.1 - 2013-07-05
591
+
592
+ * Bug fix: Setting default options on a client now works
593
+ * Bug fix: Setting options on HEAD requests now works. See #352
594
+ * Bug fix: Moving stream factory before send event to before building the stream. See #353
595
+ * Bug fix: Cookies no longer match on IP addresses per RFC 6265
596
+ * Bug fix: Correctly parsing header parameters that are in `<>` and quotes
597
+ * Added `cert` and `ssl_key` as request options
598
+ * `Host` header can now diverge from the host part of a URL if the header is set manually
599
+ * `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter
600
+ * OAuth parameters are only added via the plugin if they aren't already set
601
+ * Exceptions are now thrown when a URL cannot be parsed
602
+ * Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails
603
+ * Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin
604
+
605
+ ## 3.7.0 - 2013-06-10
606
+
607
+ * See UPGRADING.md for more information on how to upgrade.
608
+ * Requests now support the ability to specify an array of $options when creating a request to more easily modify a
609
+ request. You can pass a 'request.options' configuration setting to a client to apply default request options to
610
+ every request created by a client (e.g. default query string variables, headers, curl options, etc.).
611
+ * Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`.
612
+ See `Guzzle\Http\StaticClient::mount`.
613
+ * Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests
614
+ created by a command (e.g. custom headers, query string variables, timeout settings, etc.).
615
+ * Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the
616
+ headers of a response
617
+ * Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key
618
+ (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`)
619
+ * ServiceBuilders now support storing and retrieving arbitrary data
620
+ * CachePlugin can now purge all resources for a given URI
621
+ * CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource
622
+ * CachePlugin now uses the Vary header to determine if a resource is a cache hit
623
+ * `Guzzle\Http\Message\Response` now implements `\Serializable`
624
+ * Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters
625
+ * `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable
626
+ * Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()`
627
+ * Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size
628
+ * `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message
629
+ * Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older
630
+ Symfony users can still use the old version of Monolog.
631
+ * Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`.
632
+ Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`.
633
+ * Several performance improvements to `Guzzle\Common\Collection`
634
+ * Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
635
+ createRequest, head, delete, put, patch, post, options, prepareRequest
636
+ * Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
637
+ * Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
638
+ * Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
639
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
640
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
641
+ * Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
642
+ default `array()`
643
+ * Added `Guzzle\Stream\StreamInterface::isRepeatable`
644
+ * Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
645
+ $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
646
+ $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`.
647
+ * Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`.
648
+ * Removed `Guzzle\Http\ClientInterface::expandTemplate()`
649
+ * Removed `Guzzle\Http\ClientInterface::setRequestFactory()`
650
+ * Removed `Guzzle\Http\ClientInterface::getCurlMulti()`
651
+ * Removed `Guzzle\Http\Message\RequestInterface::canCache`
652
+ * Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`
653
+ * Removed `Guzzle\Http\Message\RequestInterface::isRedirect`
654
+ * Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
655
+ * You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting
656
+ `Guzzle\Common\Version::$emitWarnings` to true.
657
+ * Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use
658
+ `$request->getResponseBody()->isRepeatable()` instead.
659
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
660
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
661
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
662
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
663
+ * Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
664
+ * Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
665
+ * Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
666
+ * Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand.
667
+ These will work through Guzzle 4.0
668
+ * Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params].
669
+ * Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
670
+ * Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`.
671
+ * Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`.
672
+ * Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
673
+ * Marked `Guzzle\Common\Collection::inject()` as deprecated.
674
+ * Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');`
675
+ * CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
676
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
677
+ * Always setting X-cache headers on cached responses
678
+ * Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
679
+ * `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
680
+ $request, Response $response);`
681
+ * `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
682
+ * `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
683
+ * Added `CacheStorageInterface::purge($url)`
684
+ * `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
685
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
686
+ CanCacheStrategyInterface $canCache = null)`
687
+ * Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
688
+
689
+ ## 3.6.0 - 2013-05-29
690
+
691
+ * ServiceDescription now implements ToArrayInterface
692
+ * Added command.hidden_params to blacklist certain headers from being treated as additionalParameters
693
+ * Guzzle can now correctly parse incomplete URLs
694
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
695
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
696
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
697
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
698
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
699
+ CacheControl header implementation.
700
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
701
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
702
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
703
+ Guzzle\Http\Curl\RequestMediator
704
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
705
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
706
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
707
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
708
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
709
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
710
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
711
+ directly via interfaces
712
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
713
+ but are a no-op until removed.
714
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
715
+ `Guzzle\Service\Command\ArrayCommandInterface`.
716
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
717
+ on a request while the request is still being transferred
718
+ * The ability to case-insensitively search for header values
719
+ * Guzzle\Http\Message\Header::hasExactHeader
720
+ * Guzzle\Http\Message\Header::raw. Use getAll()
721
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
722
+ instead.
723
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
724
+ * Added the ability to cast Model objects to a string to view debug information.
725
+
726
+ ## 3.5.0 - 2013-05-13
727
+
728
+ * Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times
729
+ * Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove
730
+ itself from the EventDispatcher)
731
+ * Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values
732
+ * Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too
733
+ * Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a
734
+ non-existent key
735
+ * Bug: All __call() method arguments are now required (helps with mocking frameworks)
736
+ * Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
737
+ to help with refcount based garbage collection of resources created by sending a request
738
+ * Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
739
+ * Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the
740
+ HistoryPlugin for a history.
741
+ * Added a `responseBody` alias for the `response_body` location
742
+ * Refactored internals to no longer rely on Response::getRequest()
743
+ * HistoryPlugin can now be cast to a string
744
+ * HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests
745
+ and responses that are sent over the wire
746
+ * Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects
747
+
748
+ ## 3.4.3 - 2013-04-30
749
+
750
+ * Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response
751
+ * Added a check to re-extract the temp cacert bundle from the phar before sending each request
752
+
753
+ ## 3.4.2 - 2013-04-29
754
+
755
+ * Bug fix: Stream objects now work correctly with "a" and "a+" modes
756
+ * Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present
757
+ * Bug fix: AsyncPlugin no longer forces HEAD requests
758
+ * Bug fix: DateTime timezones are now properly handled when using the service description schema formatter
759
+ * Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails
760
+ * Setting a response on a request will write to the custom request body from the response body if one is specified
761
+ * LogPlugin now writes to php://output when STDERR is undefined
762
+ * Added the ability to set multiple POST files for the same key in a single call
763
+ * application/x-www-form-urlencoded POSTs now use the utf-8 charset by default
764
+ * Added the ability to queue CurlExceptions to the MockPlugin
765
+ * Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send)
766
+ * Configuration loading now allows remote files
767
+
768
+ ## 3.4.1 - 2013-04-16
769
+
770
+ * Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti
771
+ handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost.
772
+ * Exceptions are now properly grouped when sending requests in parallel
773
+ * Redirects are now properly aggregated when a multi transaction fails
774
+ * Redirects now set the response on the original object even in the event of a failure
775
+ * Bug fix: Model names are now properly set even when using $refs
776
+ * Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax
777
+ * Added support for oauth_callback in OAuth signatures
778
+ * Added support for oauth_verifier in OAuth signatures
779
+ * Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection
780
+
781
+ ## 3.4.0 - 2013-04-11
782
+
783
+ * Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
784
+ * Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
785
+ * Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
786
+ * Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
787
+ * Bug fix: Added `number` type to service descriptions.
788
+ * Bug fix: empty parameters are removed from an OAuth signature
789
+ * Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header
790
+ * Bug fix: Fixed "array to string" error when validating a union of types in a service description
791
+ * Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream
792
+ * Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin.
793
+ * Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs.
794
+ * The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections.
795
+ * Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if
796
+ the Content-Type can be determined based on the entity body or the path of the request.
797
+ * Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder.
798
+ * Added support for a PSR-3 LogAdapter.
799
+ * Added a `command.after_prepare` event
800
+ * Added `oauth_callback` parameter to the OauthPlugin
801
+ * Added the ability to create a custom stream class when using a stream factory
802
+ * Added a CachingEntityBody decorator
803
+ * Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized.
804
+ * The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar.
805
+ * You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies
806
+ * POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This
807
+ means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use
808
+ POST fields or files (the latter is only used when emulating a form POST in the browser).
809
+ * Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest
810
+
811
+ ## 3.3.1 - 2013-03-10
812
+
813
+ * Added the ability to create PHP streaming responses from HTTP requests
814
+ * Bug fix: Running any filters when parsing response headers with service descriptions
815
+ * Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing
816
+ * Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across
817
+ response location visitors.
818
+ * Bug fix: Removed the possibility of creating configuration files with circular dependencies
819
+ * RequestFactory::create() now uses the key of a POST file when setting the POST file name
820
+ * Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set
821
+
822
+ ## 3.3.0 - 2013-03-03
823
+
824
+ * A large number of performance optimizations have been made
825
+ * Bug fix: Added 'wb' as a valid write mode for streams
826
+ * Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned
827
+ * Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()`
828
+ * BC: Removed `Guzzle\Http\Utils` class
829
+ * BC: Setting a service description on a client will no longer modify the client's command factories.
830
+ * BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using
831
+ the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
832
+ * BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to
833
+ lowercase
834
+ * Operation parameter objects are now lazy loaded internally
835
+ * Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses
836
+ * Added support for instantiating responseType=class responseClass classes. Classes must implement
837
+ `Guzzle\Service\Command\ResponseClassInterface`
838
+ * Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These
839
+ additional properties also support locations and can be used to parse JSON responses where the outermost part of the
840
+ JSON is an array
841
+ * Added support for nested renaming of JSON models (rename sentAs to name)
842
+ * CachePlugin
843
+ * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error
844
+ * Debug headers can now added to cached response in the CachePlugin
845
+
846
+ ## 3.2.0 - 2013-02-14
847
+
848
+ * CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients.
849
+ * URLs with no path no longer contain a "/" by default
850
+ * Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url.
851
+ * BadResponseException no longer includes the full request and response message
852
+ * Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface
853
+ * Adding getResponseBody() to Guzzle\Http\Message\RequestInterface
854
+ * Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription
855
+ * Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list
856
+ * xmlEncoding can now be customized for the XML declaration of a XML service description operation
857
+ * Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value
858
+ aggregation and no longer uses callbacks
859
+ * The URL encoding implementation of Guzzle\Http\QueryString can now be customized
860
+ * Bug fix: Filters were not always invoked for array service description parameters
861
+ * Bug fix: Redirects now use a target response body rather than a temporary response body
862
+ * Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded
863
+ * Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives
864
+
865
+ ## 3.1.2 - 2013-01-27
866
+
867
+ * Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the
868
+ response body. For example, the XmlVisitor now parses the XML response into an array in the before() method.
869
+ * Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent
870
+ * CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444)
871
+ * Fixed a bug where redirect responses were not chained correctly using getPreviousResponse()
872
+ * Setting default headers on a client after setting the user-agent will not erase the user-agent setting
873
+
874
+ ## 3.1.1 - 2013-01-20
875
+
876
+ * Adding wildcard support to Guzzle\Common\Collection::getPath()
877
+ * Adding alias support to ServiceBuilder configs
878
+ * Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface
879
+
880
+ ## 3.1.0 - 2013-01-12
881
+
882
+ * BC: CurlException now extends from RequestException rather than BadResponseException
883
+ * BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse()
884
+ * Added getData to ServiceDescriptionInterface
885
+ * Added context array to RequestInterface::setState()
886
+ * Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http
887
+ * Bug: Adding required content-type when JSON request visitor adds JSON to a command
888
+ * Bug: Fixing the serialization of a service description with custom data
889
+ * Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing
890
+ an array of successful and failed responses
891
+ * Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection
892
+ * Added Guzzle\Http\IoEmittingEntityBody
893
+ * Moved command filtration from validators to location visitors
894
+ * Added `extends` attributes to service description parameters
895
+ * Added getModels to ServiceDescriptionInterface
896
+
897
+ ## 3.0.7 - 2012-12-19
898
+
899
+ * Fixing phar detection when forcing a cacert to system if null or true
900
+ * Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()`
901
+ * Cleaning up `Guzzle\Common\Collection::inject` method
902
+ * Adding a response_body location to service descriptions
903
+
904
+ ## 3.0.6 - 2012-12-09
905
+
906
+ * CurlMulti performance improvements
907
+ * Adding setErrorResponses() to Operation
908
+ * composer.json tweaks
909
+
910
+ ## 3.0.5 - 2012-11-18
911
+
912
+ * Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin
913
+ * Bug: Response body can now be a string containing "0"
914
+ * Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert
915
+ * Bug: QueryString::fromString now properly parses query string parameters that contain equal signs
916
+ * Added support for XML attributes in service description responses
917
+ * DefaultRequestSerializer now supports array URI parameter values for URI template expansion
918
+ * Added better mimetype guessing to requests and post files
919
+
920
+ ## 3.0.4 - 2012-11-11
921
+
922
+ * Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value
923
+ * Bug: Cookies can now be added that have a name, domain, or value set to "0"
924
+ * Bug: Using the system cacert bundle when using the Phar
925
+ * Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures
926
+ * Enhanced cookie jar de-duplication
927
+ * Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added
928
+ * Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies
929
+ * Added the ability to create any sort of hash for a stream rather than just an MD5 hash
930
+
931
+ ## 3.0.3 - 2012-11-04
932
+
933
+ * Implementing redirects in PHP rather than cURL
934
+ * Added PECL URI template extension and using as default parser if available
935
+ * Bug: Fixed Content-Length parsing of Response factory
936
+ * Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams.
937
+ * Adding ToArrayInterface throughout library
938
+ * Fixing OauthPlugin to create unique nonce values per request
939
+
940
+ ## 3.0.2 - 2012-10-25
941
+
942
+ * Magic methods are enabled by default on clients
943
+ * Magic methods return the result of a command
944
+ * Service clients no longer require a base_url option in the factory
945
+ * Bug: Fixed an issue with URI templates where null template variables were being expanded
946
+
947
+ ## 3.0.1 - 2012-10-22
948
+
949
+ * Models can now be used like regular collection objects by calling filter, map, etc.
950
+ * Models no longer require a Parameter structure or initial data in the constructor
951
+ * Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator`
952
+
953
+ ## 3.0.0 - 2012-10-15
954
+
955
+ * Rewrote service description format to be based on Swagger
956
+ * Now based on JSON schema
957
+ * Added nested input structures and nested response models
958
+ * Support for JSON and XML input and output models
959
+ * Renamed `commands` to `operations`
960
+ * Removed dot class notation
961
+ * Removed custom types
962
+ * Broke the project into smaller top-level namespaces to be more component friendly
963
+ * Removed support for XML configs and descriptions. Use arrays or JSON files.
964
+ * Removed the Validation component and Inspector
965
+ * Moved all cookie code to Guzzle\Plugin\Cookie
966
+ * Magic methods on a Guzzle\Service\Client now return the command un-executed.
967
+ * Calling getResult() or getResponse() on a command will lazily execute the command if needed.
968
+ * Now shipping with cURL's CA certs and using it by default
969
+ * Added previousResponse() method to response objects
970
+ * No longer sending Accept and Accept-Encoding headers on every request
971
+ * Only sending an Expect header by default when a payload is greater than 1MB
972
+ * Added/moved client options:
973
+ * curl.blacklist to curl.option.blacklist
974
+ * Added ssl.certificate_authority
975
+ * Added a Guzzle\Iterator component
976
+ * Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin
977
+ * Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin)
978
+ * Added a more robust caching plugin
979
+ * Added setBody to response objects
980
+ * Updating LogPlugin to use a more flexible MessageFormatter
981
+ * Added a completely revamped build process
982
+ * Cleaning up Collection class and removing default values from the get method
983
+ * Fixed ZF2 cache adapters
984
+
985
+ ## 2.8.8 - 2012-10-15
986
+
987
+ * Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did
988
+
989
+ ## 2.8.7 - 2012-09-30
990
+
991
+ * Bug: Fixed config file aliases for JSON includes
992
+ * Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests
993
+ * Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload
994
+ * Bug: Hardening request and response parsing to account for missing parts
995
+ * Bug: Fixed PEAR packaging
996
+ * Bug: Fixed Request::getInfo
997
+ * Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail
998
+ * Adding the ability for the namespace Iterator factory to look in multiple directories
999
+ * Added more getters/setters/removers from service descriptions
1000
+ * Added the ability to remove POST fields from OAuth signatures
1001
+ * OAuth plugin now supports 2-legged OAuth
1002
+
1003
+ ## 2.8.6 - 2012-09-05
1004
+
1005
+ * Added the ability to modify and build service descriptions
1006
+ * Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command
1007
+ * Added a `json` parameter location
1008
+ * Now allowing dot notation for classes in the CacheAdapterFactory
1009
+ * Using the union of two arrays rather than an array_merge when extending service builder services and service params
1010
+ * Ensuring that a service is a string before doing strpos() checks on it when substituting services for references
1011
+ in service builder config files.
1012
+ * Services defined in two different config files that include one another will by default replace the previously
1013
+ defined service, but you can now create services that extend themselves and merge their settings over the previous
1014
+ * The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like
1015
+ '_default' with a default JSON configuration file.
1016
+
1017
+ ## 2.8.5 - 2012-08-29
1018
+
1019
+ * Bug: Suppressed empty arrays from URI templates
1020
+ * Bug: Added the missing $options argument from ServiceDescription::factory to enable caching
1021
+ * Added support for HTTP responses that do not contain a reason phrase in the start-line
1022
+ * AbstractCommand commands are now invokable
1023
+ * Added a way to get the data used when signing an Oauth request before a request is sent
1024
+
1025
+ ## 2.8.4 - 2012-08-15
1026
+
1027
+ * Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin
1028
+ * Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable.
1029
+ * Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream
1030
+ * Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream
1031
+ * Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5())
1032
+ * Added additional response status codes
1033
+ * Removed SSL information from the default User-Agent header
1034
+ * DELETE requests can now send an entity body
1035
+ * Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries
1036
+ * Added the ability of the MockPlugin to consume mocked request bodies
1037
+ * LogPlugin now exposes request and response objects in the extras array
1038
+
1039
+ ## 2.8.3 - 2012-07-30
1040
+
1041
+ * Bug: Fixed a case where empty POST requests were sent as GET requests
1042
+ * Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body
1043
+ * Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new
1044
+ * Added multiple inheritance to service description commands
1045
+ * Added an ApiCommandInterface and added `getParamNames()` and `hasParam()`
1046
+ * Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything
1047
+ * Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles
1048
+
1049
+ ## 2.8.2 - 2012-07-24
1050
+
1051
+ * Bug: Query string values set to 0 are no longer dropped from the query string
1052
+ * Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()`
1053
+ * Bug: `+` is now treated as an encoded space when parsing query strings
1054
+ * QueryString and Collection performance improvements
1055
+ * Allowing dot notation for class paths in filters attribute of a service descriptions
1056
+
1057
+ ## 2.8.1 - 2012-07-16
1058
+
1059
+ * Loosening Event Dispatcher dependency
1060
+ * POST redirects can now be customized using CURLOPT_POSTREDIR
1061
+
1062
+ ## 2.8.0 - 2012-07-15
1063
+
1064
+ * BC: Guzzle\Http\Query
1065
+ * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl)
1066
+ * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding()
1067
+ * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool)
1068
+ * Changed the aggregation functions of QueryString to be static methods
1069
+ * Can now use fromString() with querystrings that have a leading ?
1070
+ * cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters
1071
+ * Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body
1072
+ * Cookies are no longer URL decoded by default
1073
+ * Bug: URI template variables set to null are no longer expanded
1074
+
1075
+ ## 2.7.2 - 2012-07-02
1076
+
1077
+ * BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser.
1078
+ * BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty()
1079
+ * CachePlugin now allows for a custom request parameter function to check if a request can be cached
1080
+ * Bug fix: CachePlugin now only caches GET and HEAD requests by default
1081
+ * Bug fix: Using header glue when transferring headers over the wire
1082
+ * Allowing deeply nested arrays for composite variables in URI templates
1083
+ * Batch divisors can now return iterators or arrays
1084
+
1085
+ ## 2.7.1 - 2012-06-26
1086
+
1087
+ * Minor patch to update version number in UA string
1088
+ * Updating build process
1089
+
1090
+ ## 2.7.0 - 2012-06-25
1091
+
1092
+ * BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes.
1093
+ * BC: Removed magic setX methods from commands
1094
+ * BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method
1095
+ * Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable.
1096
+ * Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity)
1097
+ * Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace
1098
+ * Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin
1099
+ * Added the ability to set POST fields and files in a service description
1100
+ * Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method
1101
+ * Adding a command.before_prepare event to clients
1102
+ * Added BatchClosureTransfer and BatchClosureDivisor
1103
+ * BatchTransferException now includes references to the batch divisor and transfer strategies
1104
+ * Fixed some tests so that they pass more reliably
1105
+ * Added Guzzle\Common\Log\ArrayLogAdapter
1106
+
1107
+ ## 2.6.6 - 2012-06-10
1108
+
1109
+ * BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin
1110
+ * BC: Removing Guzzle\Service\Command\CommandSet
1111
+ * Adding generic batching system (replaces the batch queue plugin and command set)
1112
+ * Updating ZF cache and log adapters and now using ZF's composer repository
1113
+ * Bug: Setting the name of each ApiParam when creating through an ApiCommand
1114
+ * Adding result_type, result_doc, deprecated, and doc_url to service descriptions
1115
+ * Bug: Changed the default cookie header casing back to 'Cookie'
1116
+
1117
+ ## 2.6.5 - 2012-06-03
1118
+
1119
+ * BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource()
1120
+ * BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from
1121
+ * BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data
1122
+ * BC: Renaming methods in the CookieJarInterface
1123
+ * Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations
1124
+ * Making the default glue for HTTP headers ';' instead of ','
1125
+ * Adding a removeValue to Guzzle\Http\Message\Header
1126
+ * Adding getCookies() to request interface.
1127
+ * Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber()
1128
+
1129
+ ## 2.6.4 - 2012-05-30
1130
+
1131
+ * BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class.
1132
+ * BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand
1133
+ * Bug: Fixing magic method command calls on clients
1134
+ * Bug: Email constraint only validates strings
1135
+ * Bug: Aggregate POST fields when POST files are present in curl handle
1136
+ * Bug: Fixing default User-Agent header
1137
+ * Bug: Only appending or prepending parameters in commands if they are specified
1138
+ * Bug: Not requiring response reason phrases or status codes to match a predefined list of codes
1139
+ * Allowing the use of dot notation for class namespaces when using instance_of constraint
1140
+ * Added any_match validation constraint
1141
+ * Added an AsyncPlugin
1142
+ * Passing request object to the calculateWait method of the ExponentialBackoffPlugin
1143
+ * Allowing the result of a command object to be changed
1144
+ * Parsing location and type sub values when instantiating a service description rather than over and over at runtime
1145
+
1146
+ ## 2.6.3 - 2012-05-23
1147
+
1148
+ * [BC] Guzzle\Common\FromConfigInterface no longer requires any config options.
1149
+ * [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields.
1150
+ * You can now use an array of data when creating PUT request bodies in the request factory.
1151
+ * Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable.
1152
+ * [Http] Adding support for Content-Type in multipart POST uploads per upload
1153
+ * [Http] Added support for uploading multiple files using the same name (foo[0], foo[1])
1154
+ * Adding more POST data operations for easier manipulation of POST data.
1155
+ * You can now set empty POST fields.
1156
+ * The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files.
1157
+ * Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate.
1158
+ * CS updates
1159
+
1160
+ ## 2.6.2 - 2012-05-19
1161
+
1162
+ * [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method.
1163
+
1164
+ ## 2.6.1 - 2012-05-19
1165
+
1166
+ * [BC] Removing 'path' support in service descriptions. Use 'uri'.
1167
+ * [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache.
1168
+ * [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it.
1169
+ * [BC] Removing Guzzle\Common\XmlElement.
1170
+ * All commands, both dynamic and concrete, have ApiCommand objects.
1171
+ * Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits.
1172
+ * Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored.
1173
+ * Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible.
1174
+
1175
+ ## 2.6.0 - 2012-05-15
1176
+
1177
+ * [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder
1178
+ * [BC] Executing a Command returns the result of the command rather than the command
1179
+ * [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed.
1180
+ * [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args.
1181
+ * [BC] Moving ResourceIterator* to Guzzle\Service\Resource
1182
+ * [BC] Completely refactored ResourceIterators to iterate over a cloned command object
1183
+ * [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate
1184
+ * [BC] Guzzle\Guzzle is now deprecated
1185
+ * Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject
1186
+ * Adding Guzzle\Version class to give version information about Guzzle
1187
+ * Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate()
1188
+ * Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data
1189
+ * ServiceDescription and ServiceBuilder are now cacheable using similar configs
1190
+ * Changing the format of XML and JSON service builder configs. Backwards compatible.
1191
+ * Cleaned up Cookie parsing
1192
+ * Trimming the default Guzzle User-Agent header
1193
+ * Adding a setOnComplete() method to Commands that is called when a command completes
1194
+ * Keeping track of requests that were mocked in the MockPlugin
1195
+ * Fixed a caching bug in the CacheAdapterFactory
1196
+ * Inspector objects can be injected into a Command object
1197
+ * Refactoring a lot of code and tests to be case insensitive when dealing with headers
1198
+ * Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL
1199
+ * Adding the ability to set global option overrides to service builder configs
1200
+ * Adding the ability to include other service builder config files from within XML and JSON files
1201
+ * Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method.
1202
+
1203
+ ## 2.5.0 - 2012-05-08
1204
+
1205
+ * Major performance improvements
1206
+ * [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated.
1207
+ * [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component.
1208
+ * [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}"
1209
+ * Added the ability to passed parameters to all requests created by a client
1210
+ * Added callback functionality to the ExponentialBackoffPlugin
1211
+ * Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies.
1212
+ * Rewinding request stream bodies when retrying requests
1213
+ * Exception is thrown when JSON response body cannot be decoded
1214
+ * Added configurable magic method calls to clients and commands. This is off by default.
1215
+ * Fixed a defect that added a hash to every parsed URL part
1216
+ * Fixed duplicate none generation for OauthPlugin.
1217
+ * Emitting an event each time a client is generated by a ServiceBuilder
1218
+ * Using an ApiParams object instead of a Collection for parameters of an ApiCommand
1219
+ * cache.* request parameters should be renamed to params.cache.*
1220
+ * Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle.
1221
+ * Added the ability to disable type validation of service descriptions
1222
+ * ServiceDescriptions and ServiceBuilders are now Serializable
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle, PHP HTTP client
2
+ =======================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/guzzle/guzzle.svg?branch=master)](http://travis-ci.org/guzzle/guzzle)
5
+
6
+ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
7
+ trivial to integrate with web services.
8
+
9
+ - Simple interface for building query strings, POST requests, streaming large
10
+ uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
11
+ etc...
12
+ - Can send both synchronous and asynchronous requests using the same interface.
13
+ - Uses PSR-7 interfaces for requests, responses, and streams. This allows you
14
+ to utilize other PSR-7 compatible libraries with Guzzle.
15
+ - Abstracts away the underlying HTTP transport, allowing you to write
16
+ environment and transport agnostic code; i.e., no hard dependency on cURL,
17
+ PHP streams, sockets, or non-blocking event loops.
18
+ - Middleware system allows you to augment and compose client behavior.
19
+
20
+ ```php
21
+ $client = new GuzzleHttp\Client();
22
+ $res = $client->request('GET', 'https://api.github.com/user', [
23
+ 'auth' => ['user', 'pass']
24
+ ]);
25
+ echo $res->getStatusCode();
26
+ // 200
27
+ echo $res->getHeaderLine('content-type');
28
+ // 'application/json; charset=utf8'
29
+ echo $res->getBody();
30
+ // {"type":"User"...'
31
+
32
+ // Send an asynchronous request.
33
+ $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
34
+ $promise = $client->sendAsync($request)->then(function ($response) {
35
+ echo 'I completed! ' . $response->getBody();
36
+ });
37
+ $promise->wait();
38
+ ```
39
+
40
+ ## Help and docs
41
+
42
+ - [Documentation](http://guzzlephp.org/)
43
+ - [stackoverflow](http://stackoverflow.com/questions/tagged/guzzle)
44
+ - [Gitter](https://gitter.im/guzzle/guzzle)
45
+
46
+
47
+ ## Installing Guzzle
48
+
49
+ The recommended way to install Guzzle is through
50
+ [Composer](http://getcomposer.org).
51
+
52
+ ```bash
53
+ # Install Composer
54
+ curl -sS https://getcomposer.org/installer | php
55
+ ```
56
+
57
+ Next, run the Composer command to install the latest stable version of Guzzle:
58
+
59
+ ```bash
60
+ composer.phar require guzzlehttp/guzzle
61
+ ```
62
+
63
+ After installing, you need to require Composer's autoloader:
64
+
65
+ ```php
66
+ require 'vendor/autoload.php';
67
+ ```
68
+
69
+ You can then later update Guzzle using composer:
70
+
71
+ ```bash
72
+ composer.phar update
73
+ ```
74
+
75
+
76
+ ## Version Guidance
77
+
78
+ | Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 |
79
+ |---------|-------------|---------------------|--------------|---------------------|---------------------|-------|
80
+ | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No |
81
+ | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | N/A | N/A | No |
82
+ | 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No |
83
+ | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes |
84
+
85
+ [guzzle-3-repo]: https://github.com/guzzle/guzzle3
86
+ [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
87
+ [guzzle-6-repo]: https://github.com/guzzle/guzzle
88
+ [guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
89
+ [guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
90
+ [guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/UPGRADING.md ADDED
@@ -0,0 +1,1203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle Upgrade Guide
2
+ ====================
3
+
4
+ 5.0 to 6.0
5
+ ----------
6
+
7
+ Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages.
8
+ Due to the fact that these messages are immutable, this prompted a refactoring
9
+ of Guzzle to use a middleware based system rather than an event system. Any
10
+ HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be
11
+ updated to work with the new immutable PSR-7 request and response objects. Any
12
+ event listeners or subscribers need to be updated to become middleware
13
+ functions that wrap handlers (or are injected into a
14
+ `GuzzleHttp\HandlerStack`).
15
+
16
+ - Removed `GuzzleHttp\BatchResults`
17
+ - Removed `GuzzleHttp\Collection`
18
+ - Removed `GuzzleHttp\HasDataTrait`
19
+ - Removed `GuzzleHttp\ToArrayInterface`
20
+ - The `guzzlehttp/streams` dependency has been removed. Stream functionality
21
+ is now present in the `GuzzleHttp\Psr7` namespace provided by the
22
+ `guzzlehttp/psr7` package.
23
+ - Guzzle no longer uses ReactPHP promises and now uses the
24
+ `guzzlehttp/promises` library. We use a custom promise library for three
25
+ significant reasons:
26
+ 1. React promises (at the time of writing this) are recursive. Promise
27
+ chaining and promise resolution will eventually blow the stack. Guzzle
28
+ promises are not recursive as they use a sort of trampolining technique.
29
+ Note: there has been movement in the React project to modify promises to
30
+ no longer utilize recursion.
31
+ 2. Guzzle needs to have the ability to synchronously block on a promise to
32
+ wait for a result. Guzzle promises allows this functionality (and does
33
+ not require the use of recursion).
34
+ 3. Because we need to be able to wait on a result, doing so using React
35
+ promises requires wrapping react promises with RingPHP futures. This
36
+ overhead is no longer needed, reducing stack sizes, reducing complexity,
37
+ and improving performance.
38
+ - `GuzzleHttp\Mimetypes` has been moved to a function in
39
+ `GuzzleHttp\Psr7\mimetype_from_extension` and
40
+ `GuzzleHttp\Psr7\mimetype_from_filename`.
41
+ - `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query
42
+ strings must now be passed into request objects as strings, or provided to
43
+ the `query` request option when creating requests with clients. The `query`
44
+ option uses PHP's `http_build_query` to convert an array to a string. If you
45
+ need a different serialization technique, you will need to pass the query
46
+ string in as a string. There are a couple helper functions that will make
47
+ working with query strings easier: `GuzzleHttp\Psr7\parse_query` and
48
+ `GuzzleHttp\Psr7\build_query`.
49
+ - Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware
50
+ system based on PSR-7, using RingPHP and it's middleware system as well adds
51
+ more complexity than the benefits it provides. All HTTP handlers that were
52
+ present in RingPHP have been modified to work directly with PSR-7 messages
53
+ and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces
54
+ complexity in Guzzle, removes a dependency, and improves performance. RingPHP
55
+ will be maintained for Guzzle 5 support, but will no longer be a part of
56
+ Guzzle 6.
57
+ - As Guzzle now uses a middleware based systems the event system and RingPHP
58
+ integration has been removed. Note: while the event system has been removed,
59
+ it is possible to add your own type of event system that is powered by the
60
+ middleware system.
61
+ - Removed the `Event` namespace.
62
+ - Removed the `Subscriber` namespace.
63
+ - Removed `Transaction` class
64
+ - Removed `RequestFsm`
65
+ - Removed `RingBridge`
66
+ - `GuzzleHttp\Subscriber\Cookie` is now provided by
67
+ `GuzzleHttp\Middleware::cookies`
68
+ - `GuzzleHttp\Subscriber\HttpError` is now provided by
69
+ `GuzzleHttp\Middleware::httpError`
70
+ - `GuzzleHttp\Subscriber\History` is now provided by
71
+ `GuzzleHttp\Middleware::history`
72
+ - `GuzzleHttp\Subscriber\Mock` is now provided by
73
+ `GuzzleHttp\Handler\MockHandler`
74
+ - `GuzzleHttp\Subscriber\Prepare` is now provided by
75
+ `GuzzleHttp\PrepareBodyMiddleware`
76
+ - `GuzzleHttp\Subscriber\Redirect` is now provided by
77
+ `GuzzleHttp\RedirectMiddleware`
78
+ - Guzzle now uses `Psr\Http\Message\UriInterface` (implements in
79
+ `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone.
80
+ - Static functions in `GuzzleHttp\Utils` have been moved to namespaced
81
+ functions under the `GuzzleHttp` namespace. This requires either a Composer
82
+ based autoloader or you to include functions.php.
83
+ - `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to
84
+ `GuzzleHttp\ClientInterface::getConfig`.
85
+ - `GuzzleHttp\ClientInterface::setDefaultOption` has been removed.
86
+ - The `json` and `xml` methods of response objects has been removed. With the
87
+ migration to strictly adhering to PSR-7 as the interface for Guzzle messages,
88
+ adding methods to message interfaces would actually require Guzzle messages
89
+ to extend from PSR-7 messages rather then work with them directly.
90
+
91
+ ## Migrating to middleware
92
+
93
+ The change to PSR-7 unfortunately required significant refactoring to Guzzle
94
+ due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event
95
+ system from plugins. The event system relied on mutability of HTTP messages and
96
+ side effects in order to work. With immutable messages, you have to change your
97
+ workflow to become more about either returning a value (e.g., functional
98
+ middlewares) or setting a value on an object. Guzzle v6 has chosen the
99
+ functional middleware approach.
100
+
101
+ Instead of using the event system to listen for things like the `before` event,
102
+ you now create a stack based middleware function that intercepts a request on
103
+ the way in and the promise of the response on the way out. This is a much
104
+ simpler and more predictable approach than the event system and works nicely
105
+ with PSR-7 middleware. Due to the use of promises, the middleware system is
106
+ also asynchronous.
107
+
108
+ v5:
109
+
110
+ ```php
111
+ use GuzzleHttp\Event\BeforeEvent;
112
+ $client = new GuzzleHttp\Client();
113
+ // Get the emitter and listen to the before event.
114
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
115
+ // Guzzle v5 events relied on mutation
116
+ $e->getRequest()->setHeader('X-Foo', 'Bar');
117
+ });
118
+ ```
119
+
120
+ v6:
121
+
122
+ In v6, you can modify the request before it is sent using the `mapRequest`
123
+ middleware. The idiomatic way in v6 to modify the request/response lifecycle is
124
+ to setup a handler middleware stack up front and inject the handler into a
125
+ client.
126
+
127
+ ```php
128
+ use GuzzleHttp\Middleware;
129
+ // Create a handler stack that has all of the default middlewares attached
130
+ $handler = GuzzleHttp\HandlerStack::create();
131
+ // Push the handler onto the handler stack
132
+ $handler->push(Middleware::mapRequest(function (RequestInterface $request) {
133
+ // Notice that we have to return a request object
134
+ return $request->withHeader('X-Foo', 'Bar');
135
+ });
136
+ // Inject the handler into the client
137
+ $client = new GuzzleHttp\Client(['handler' => $handler]);
138
+ ```
139
+
140
+ ## POST Requests
141
+
142
+ This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params)
143
+ and `multipart` request options. `form_params` is an associative array of
144
+ strings or array of strings and is used to serialize an
145
+ `application/x-www-form-urlencoded` POST request. The
146
+ [`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart)
147
+ option is now used to send a multipart/form-data POST request.
148
+
149
+ `GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add
150
+ POST files to a multipart/form-data request.
151
+
152
+ The `body` option no longer accepts an array to send POST requests. Please use
153
+ `multipart` or `form_params` instead.
154
+
155
+ The `base_url` option has been renamed to `base_uri`.
156
+
157
+ 4.x to 5.0
158
+ ----------
159
+
160
+ ## Rewritten Adapter Layer
161
+
162
+ Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send
163
+ HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
164
+ is still supported, but it has now been renamed to `handler`. Instead of
165
+ passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
166
+ `callable` that follows the RingPHP specification.
167
+
168
+ ## Removed Fluent Interfaces
169
+
170
+ [Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil)
171
+ from the following classes:
172
+
173
+ - `GuzzleHttp\Collection`
174
+ - `GuzzleHttp\Url`
175
+ - `GuzzleHttp\Query`
176
+ - `GuzzleHttp\Post\PostBody`
177
+ - `GuzzleHttp\Cookie\SetCookie`
178
+
179
+ ## Removed functions.php
180
+
181
+ Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following
182
+ functions can be used as replacements.
183
+
184
+ - `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode`
185
+ - `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath`
186
+ - `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path`
187
+ - `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however,
188
+ deprecated in favor of using `GuzzleHttp\Pool::batch()`.
189
+
190
+ The "procedural" global client has been removed with no replacement (e.g.,
191
+ `GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client`
192
+ object as a replacement.
193
+
194
+ ## `throwImmediately` has been removed
195
+
196
+ The concept of "throwImmediately" has been removed from exceptions and error
197
+ events. This control mechanism was used to stop a transfer of concurrent
198
+ requests from completing. This can now be handled by throwing the exception or
199
+ by cancelling a pool of requests or each outstanding future request
200
+ individually.
201
+
202
+ ## headers event has been removed
203
+
204
+ Removed the "headers" event. This event was only useful for changing the
205
+ body a response once the headers of the response were known. You can implement
206
+ a similar behavior in a number of ways. One example might be to use a
207
+ FnStream that has access to the transaction being sent. For example, when the
208
+ first byte is written, you could check if the response headers match your
209
+ expectations, and if so, change the actual stream body that is being
210
+ written to.
211
+
212
+ ## Updates to HTTP Messages
213
+
214
+ Removed the `asArray` parameter from
215
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
216
+ value as an array, then use the newly added `getHeaderAsArray()` method of
217
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
218
+ the PSR-7 interfaces.
219
+
220
+ 3.x to 4.0
221
+ ----------
222
+
223
+ ## Overarching changes:
224
+
225
+ - Now requires PHP 5.4 or greater.
226
+ - No longer requires cURL to send requests.
227
+ - Guzzle no longer wraps every exception it throws. Only exceptions that are
228
+ recoverable are now wrapped by Guzzle.
229
+ - Various namespaces have been removed or renamed.
230
+ - No longer requiring the Symfony EventDispatcher. A custom event dispatcher
231
+ based on the Symfony EventDispatcher is
232
+ now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant
233
+ speed and functionality improvements).
234
+
235
+ Changes per Guzzle 3.x namespace are described below.
236
+
237
+ ## Batch
238
+
239
+ The `Guzzle\Batch` namespace has been removed. This is best left to
240
+ third-parties to implement on top of Guzzle's core HTTP library.
241
+
242
+ ## Cache
243
+
244
+ The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement
245
+ has been implemented yet, but hoping to utilize a PSR cache interface).
246
+
247
+ ## Common
248
+
249
+ - Removed all of the wrapped exceptions. It's better to use the standard PHP
250
+ library for unrecoverable exceptions.
251
+ - `FromConfigInterface` has been removed.
252
+ - `Guzzle\Common\Version` has been removed. The VERSION constant can be found
253
+ at `GuzzleHttp\ClientInterface::VERSION`.
254
+
255
+ ### Collection
256
+
257
+ - `getAll` has been removed. Use `toArray` to convert a collection to an array.
258
+ - `inject` has been removed.
259
+ - `keySearch` has been removed.
260
+ - `getPath` no longer supports wildcard expressions. Use something better like
261
+ JMESPath for this.
262
+ - `setPath` now supports appending to an existing array via the `[]` notation.
263
+
264
+ ### Events
265
+
266
+ Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses
267
+ `GuzzleHttp\Event\Emitter`.
268
+
269
+ - `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by
270
+ `GuzzleHttp\Event\EmitterInterface`.
271
+ - `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by
272
+ `GuzzleHttp\Event\Emitter`.
273
+ - `Symfony\Component\EventDispatcher\Event` is replaced by
274
+ `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in
275
+ `GuzzleHttp\Event\EventInterface`.
276
+ - `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and
277
+ `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the
278
+ event emitter of a request, client, etc. now uses the `getEmitter` method
279
+ rather than the `getDispatcher` method.
280
+
281
+ #### Emitter
282
+
283
+ - Use the `once()` method to add a listener that automatically removes itself
284
+ the first time it is invoked.
285
+ - Use the `listeners()` method to retrieve a list of event listeners rather than
286
+ the `getListeners()` method.
287
+ - Use `emit()` instead of `dispatch()` to emit an event from an emitter.
288
+ - Use `attach()` instead of `addSubscriber()` and `detach()` instead of
289
+ `removeSubscriber()`.
290
+
291
+ ```php
292
+ $mock = new Mock();
293
+ // 3.x
294
+ $request->getEventDispatcher()->addSubscriber($mock);
295
+ $request->getEventDispatcher()->removeSubscriber($mock);
296
+ // 4.x
297
+ $request->getEmitter()->attach($mock);
298
+ $request->getEmitter()->detach($mock);
299
+ ```
300
+
301
+ Use the `on()` method to add a listener rather than the `addListener()` method.
302
+
303
+ ```php
304
+ // 3.x
305
+ $request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } );
306
+ // 4.x
307
+ $request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } );
308
+ ```
309
+
310
+ ## Http
311
+
312
+ ### General changes
313
+
314
+ - The cacert.pem certificate has been moved to `src/cacert.pem`.
315
+ - Added the concept of adapters that are used to transfer requests over the
316
+ wire.
317
+ - Simplified the event system.
318
+ - Sending requests in parallel is still possible, but batching is no longer a
319
+ concept of the HTTP layer. Instead, you must use the `complete` and `error`
320
+ events to asynchronously manage parallel request transfers.
321
+ - `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`.
322
+ - `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`.
323
+ - QueryAggregators have been rewritten so that they are simply callable
324
+ functions.
325
+ - `GuzzleHttp\StaticClient` has been removed. Use the functions provided in
326
+ `functions.php` for an easy to use static client instance.
327
+ - Exceptions in `GuzzleHttp\Exception` have been updated to all extend from
328
+ `GuzzleHttp\Exception\TransferException`.
329
+
330
+ ### Client
331
+
332
+ Calling methods like `get()`, `post()`, `head()`, etc. no longer create and
333
+ return a request, but rather creates a request, sends the request, and returns
334
+ the response.
335
+
336
+ ```php
337
+ // 3.0
338
+ $request = $client->get('/');
339
+ $response = $request->send();
340
+
341
+ // 4.0
342
+ $response = $client->get('/');
343
+
344
+ // or, to mirror the previous behavior
345
+ $request = $client->createRequest('GET', '/');
346
+ $response = $client->send($request);
347
+ ```
348
+
349
+ `GuzzleHttp\ClientInterface` has changed.
350
+
351
+ - The `send` method no longer accepts more than one request. Use `sendAll` to
352
+ send multiple requests in parallel.
353
+ - `setUserAgent()` has been removed. Use a default request option instead. You
354
+ could, for example, do something like:
355
+ `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
356
+ - `setSslVerification()` has been removed. Use default request options instead,
357
+ like `$client->setConfig('defaults/verify', true)`.
358
+
359
+ `GuzzleHttp\Client` has changed.
360
+
361
+ - The constructor now accepts only an associative array. You can include a
362
+ `base_url` string or array to use a URI template as the base URL of a client.
363
+ You can also specify a `defaults` key that is an associative array of default
364
+ request options. You can pass an `adapter` to use a custom adapter,
365
+ `batch_adapter` to use a custom adapter for sending requests in parallel, or
366
+ a `message_factory` to change the factory used to create HTTP requests and
367
+ responses.
368
+ - The client no longer emits a `client.create_request` event.
369
+ - Creating requests with a client no longer automatically utilize a URI
370
+ template. You must pass an array into a creational method (e.g.,
371
+ `createRequest`, `get`, `put`, etc.) in order to expand a URI template.
372
+
373
+ ### Messages
374
+
375
+ Messages no longer have references to their counterparts (i.e., a request no
376
+ longer has a reference to it's response, and a response no loger has a
377
+ reference to its request). This association is now managed through a
378
+ `GuzzleHttp\Adapter\TransactionInterface` object. You can get references to
379
+ these transaction objects using request events that are emitted over the
380
+ lifecycle of a request.
381
+
382
+ #### Requests with a body
383
+
384
+ - `GuzzleHttp\Message\EntityEnclosingRequest` and
385
+ `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The
386
+ separation between requests that contain a body and requests that do not
387
+ contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface`
388
+ handles both use cases.
389
+ - Any method that previously accepts a `GuzzleHttp\Response` object now accept a
390
+ `GuzzleHttp\Message\ResponseInterface`.
391
+ - `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to
392
+ `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create
393
+ both requests and responses and is implemented in
394
+ `GuzzleHttp\Message\MessageFactory`.
395
+ - POST field and file methods have been removed from the request object. You
396
+ must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface`
397
+ to control the format of a POST body. Requests that are created using a
398
+ standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use
399
+ a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if
400
+ the method is POST and no body is provided.
401
+
402
+ ```php
403
+ $request = $client->createRequest('POST', '/');
404
+ $request->getBody()->setField('foo', 'bar');
405
+ $request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r')));
406
+ ```
407
+
408
+ #### Headers
409
+
410
+ - `GuzzleHttp\Message\Header` has been removed. Header values are now simply
411
+ represented by an array of values or as a string. Header values are returned
412
+ as a string by default when retrieving a header value from a message. You can
413
+ pass an optional argument of `true` to retrieve a header value as an array
414
+ of strings instead of a single concatenated string.
415
+ - `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to
416
+ `GuzzleHttp\Post`. This interface has been simplified and now allows the
417
+ addition of arbitrary headers.
418
+ - Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most
419
+ of the custom headers are now handled separately in specific
420
+ subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has
421
+ been updated to properly handle headers that contain parameters (like the
422
+ `Link` header).
423
+
424
+ #### Responses
425
+
426
+ - `GuzzleHttp\Message\Response::getInfo()` and
427
+ `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event
428
+ system to retrieve this type of information.
429
+ - `GuzzleHttp\Message\Response::getRawHeaders()` has been removed.
430
+ - `GuzzleHttp\Message\Response::getMessage()` has been removed.
431
+ - `GuzzleHttp\Message\Response::calculateAge()` and other cache specific
432
+ methods have moved to the CacheSubscriber.
433
+ - Header specific helper functions like `getContentMd5()` have been removed.
434
+ Just use `getHeader('Content-MD5')` instead.
435
+ - `GuzzleHttp\Message\Response::setRequest()` and
436
+ `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event
437
+ system to work with request and response objects as a transaction.
438
+ - `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the
439
+ Redirect subscriber instead.
440
+ - `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have
441
+ been removed. Use `getStatusCode()` instead.
442
+
443
+ #### Streaming responses
444
+
445
+ Streaming requests can now be created by a client directly, returning a
446
+ `GuzzleHttp\Message\ResponseInterface` object that contains a body stream
447
+ referencing an open PHP HTTP stream.
448
+
449
+ ```php
450
+ // 3.0
451
+ use Guzzle\Stream\PhpStreamRequestFactory;
452
+ $request = $client->get('/');
453
+ $factory = new PhpStreamRequestFactory();
454
+ $stream = $factory->fromRequest($request);
455
+ $data = $stream->read(1024);
456
+
457
+ // 4.0
458
+ $response = $client->get('/', ['stream' => true]);
459
+ // Read some data off of the stream in the response body
460
+ $data = $response->getBody()->read(1024);
461
+ ```
462
+
463
+ #### Redirects
464
+
465
+ The `configureRedirects()` method has been removed in favor of a
466
+ `allow_redirects` request option.
467
+
468
+ ```php
469
+ // Standard redirects with a default of a max of 5 redirects
470
+ $request = $client->createRequest('GET', '/', ['allow_redirects' => true]);
471
+
472
+ // Strict redirects with a custom number of redirects
473
+ $request = $client->createRequest('GET', '/', [
474
+ 'allow_redirects' => ['max' => 5, 'strict' => true]
475
+ ]);
476
+ ```
477
+
478
+ #### EntityBody
479
+
480
+ EntityBody interfaces and classes have been removed or moved to
481
+ `GuzzleHttp\Stream`. All classes and interfaces that once required
482
+ `GuzzleHttp\EntityBodyInterface` now require
483
+ `GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no
484
+ longer uses `GuzzleHttp\EntityBody::factory` but now uses
485
+ `GuzzleHttp\Stream\Stream::factory` or even better:
486
+ `GuzzleHttp\Stream\create()`.
487
+
488
+ - `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface`
489
+ - `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream`
490
+ - `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream`
491
+ - `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream`
492
+ - `Guzzle\Http\IoEmittyinEntityBody` has been removed.
493
+
494
+ #### Request lifecycle events
495
+
496
+ Requests previously submitted a large number of requests. The number of events
497
+ emitted over the lifecycle of a request has been significantly reduced to make
498
+ it easier to understand how to extend the behavior of a request. All events
499
+ emitted during the lifecycle of a request now emit a custom
500
+ `GuzzleHttp\Event\EventInterface` object that contains context providing
501
+ methods and a way in which to modify the transaction at that specific point in
502
+ time (e.g., intercept the request and set a response on the transaction).
503
+
504
+ - `request.before_send` has been renamed to `before` and now emits a
505
+ `GuzzleHttp\Event\BeforeEvent`
506
+ - `request.complete` has been renamed to `complete` and now emits a
507
+ `GuzzleHttp\Event\CompleteEvent`.
508
+ - `request.sent` has been removed. Use `complete`.
509
+ - `request.success` has been removed. Use `complete`.
510
+ - `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`.
511
+ - `request.exception` has been removed. Use `error`.
512
+ - `request.receive.status_line` has been removed.
513
+ - `curl.callback.progress` has been removed. Use a custom `StreamInterface` to
514
+ maintain a status update.
515
+ - `curl.callback.write` has been removed. Use a custom `StreamInterface` to
516
+ intercept writes.
517
+ - `curl.callback.read` has been removed. Use a custom `StreamInterface` to
518
+ intercept reads.
519
+
520
+ `headers` is a new event that is emitted after the response headers of a
521
+ request have been received before the body of the response is downloaded. This
522
+ event emits a `GuzzleHttp\Event\HeadersEvent`.
523
+
524
+ You can intercept a request and inject a response using the `intercept()` event
525
+ of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
526
+ `GuzzleHttp\Event\ErrorEvent` event.
527
+
528
+ See: http://docs.guzzlephp.org/en/latest/events.html
529
+
530
+ ## Inflection
531
+
532
+ The `Guzzle\Inflection` namespace has been removed. This is not a core concern
533
+ of Guzzle.
534
+
535
+ ## Iterator
536
+
537
+ The `Guzzle\Iterator` namespace has been removed.
538
+
539
+ - `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and
540
+ `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of
541
+ Guzzle itself.
542
+ - `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent
543
+ class is shipped with PHP 5.4.
544
+ - `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because
545
+ it's easier to just wrap an iterator in a generator that maps values.
546
+
547
+ For a replacement of these iterators, see https://github.com/nikic/iter
548
+
549
+ ## Log
550
+
551
+ The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The
552
+ `Guzzle\Log` namespace has been removed. Guzzle now relies on
553
+ `Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been
554
+ moved to `GuzzleHttp\Subscriber\Log\Formatter`.
555
+
556
+ ## Parser
557
+
558
+ The `Guzzle\Parser` namespace has been removed. This was previously used to
559
+ make it possible to plug in custom parsers for cookies, messages, URI
560
+ templates, and URLs; however, this level of complexity is not needed in Guzzle
561
+ so it has been removed.
562
+
563
+ - Cookie: Cookie parsing logic has been moved to
564
+ `GuzzleHttp\Cookie\SetCookie::fromString`.
565
+ - Message: Message parsing logic for both requests and responses has been moved
566
+ to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only
567
+ used in debugging or deserializing messages, so it doesn't make sense for
568
+ Guzzle as a library to add this level of complexity to parsing messages.
569
+ - UriTemplate: URI template parsing has been moved to
570
+ `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL
571
+ URI template library if it is installed.
572
+ - Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously
573
+ it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary,
574
+ then developers are free to subclass `GuzzleHttp\Url`.
575
+
576
+ ## Plugin
577
+
578
+ The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`.
579
+ Several plugins are shipping with the core Guzzle library under this namespace.
580
+
581
+ - `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar
582
+ code has moved to `GuzzleHttp\Cookie`.
583
+ - `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin.
584
+ - `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is
585
+ received.
586
+ - `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin.
587
+ - `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before
588
+ sending. This subscriber is attached to all requests by default.
589
+ - `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin.
590
+
591
+ The following plugins have been removed (third-parties are free to re-implement
592
+ these if needed):
593
+
594
+ - `GuzzleHttp\Plugin\Async` has been removed.
595
+ - `GuzzleHttp\Plugin\CurlAuth` has been removed.
596
+ - `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This
597
+ functionality should instead be implemented with event listeners that occur
598
+ after normal response parsing occurs in the guzzle/command package.
599
+
600
+ The following plugins are not part of the core Guzzle package, but are provided
601
+ in separate repositories:
602
+
603
+ - `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler
604
+ to build custom retry policies using simple functions rather than various
605
+ chained classes. See: https://github.com/guzzle/retry-subscriber
606
+ - `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
607
+ https://github.com/guzzle/cache-subscriber
608
+ - `Guzzle\Http\Plugin\Log\LogPlugin` has moved to
609
+ https://github.com/guzzle/log-subscriber
610
+ - `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to
611
+ https://github.com/guzzle/message-integrity-subscriber
612
+ - `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to
613
+ `GuzzleHttp\Subscriber\MockSubscriber`.
614
+ - `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to
615
+ https://github.com/guzzle/oauth-subscriber
616
+
617
+ ## Service
618
+
619
+ The service description layer of Guzzle has moved into two separate packages:
620
+
621
+ - http://github.com/guzzle/command Provides a high level abstraction over web
622
+ services by representing web service operations using commands.
623
+ - http://github.com/guzzle/guzzle-services Provides an implementation of
624
+ guzzle/command that provides request serialization and response parsing using
625
+ Guzzle service descriptions.
626
+
627
+ ## Stream
628
+
629
+ Stream have moved to a separate package available at
630
+ https://github.com/guzzle/streams.
631
+
632
+ `Guzzle\Stream\StreamInterface` has been given a large update to cleanly take
633
+ on the responsibilities of `Guzzle\Http\EntityBody` and
634
+ `Guzzle\Http\EntityBodyInterface` now that they have been removed. The number
635
+ of methods implemented by the `StreamInterface` has been drastically reduced to
636
+ allow developers to more easily extend and decorate stream behavior.
637
+
638
+ ## Removed methods from StreamInterface
639
+
640
+ - `getStream` and `setStream` have been removed to better encapsulate streams.
641
+ - `getMetadata` and `setMetadata` have been removed in favor of
642
+ `GuzzleHttp\Stream\MetadataStreamInterface`.
643
+ - `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been
644
+ removed. This data is accessible when
645
+ using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
646
+ - `rewind` has been removed. Use `seek(0)` for a similar behavior.
647
+
648
+ ## Renamed methods
649
+
650
+ - `detachStream` has been renamed to `detach`.
651
+ - `feof` has been renamed to `eof`.
652
+ - `ftell` has been renamed to `tell`.
653
+ - `readLine` has moved from an instance method to a static class method of
654
+ `GuzzleHttp\Stream\Stream`.
655
+
656
+ ## Metadata streams
657
+
658
+ `GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams
659
+ that contain additional metadata accessible via `getMetadata()`.
660
+ `GuzzleHttp\Stream\StreamInterface::getMetadata` and
661
+ `GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed.
662
+
663
+ ## StreamRequestFactory
664
+
665
+ The entire concept of the StreamRequestFactory has been removed. The way this
666
+ was used in Guzzle 3 broke the actual interface of sending streaming requests
667
+ (instead of getting back a Response, you got a StreamInterface). Streeaming
668
+ PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`.
669
+
670
+ 3.6 to 3.7
671
+ ----------
672
+
673
+ ### Deprecations
674
+
675
+ - You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.:
676
+
677
+ ```php
678
+ \Guzzle\Common\Version::$emitWarnings = true;
679
+ ```
680
+
681
+ The following APIs and options have been marked as deprecated:
682
+
683
+ - Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead.
684
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
685
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
686
+ - Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
687
+ - Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
688
+ - Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
689
+ - Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
690
+ - Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
691
+ - Marked `Guzzle\Common\Collection::inject()` as deprecated.
692
+ - Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use
693
+ `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or
694
+ `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));`
695
+
696
+ 3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational
697
+ request methods. When paired with a client's configuration settings, these options allow you to specify default settings
698
+ for various aspects of a request. Because these options make other previous configuration options redundant, several
699
+ configuration options and methods of a client and AbstractCommand have been deprecated.
700
+
701
+ - Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`.
702
+ - Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`.
703
+ - Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')`
704
+ - Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0
705
+
706
+ $command = $client->getCommand('foo', array(
707
+ 'command.headers' => array('Test' => '123'),
708
+ 'command.response_body' => '/path/to/file'
709
+ ));
710
+
711
+ // Should be changed to:
712
+
713
+ $command = $client->getCommand('foo', array(
714
+ 'command.request_options' => array(
715
+ 'headers' => array('Test' => '123'),
716
+ 'save_as' => '/path/to/file'
717
+ )
718
+ ));
719
+
720
+ ### Interface changes
721
+
722
+ Additions and changes (you will need to update any implementations or subclasses you may have created):
723
+
724
+ - Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
725
+ createRequest, head, delete, put, patch, post, options, prepareRequest
726
+ - Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
727
+ - Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
728
+ - Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
729
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
730
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
731
+ - Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
732
+ default `array()`
733
+ - Added `Guzzle\Stream\StreamInterface::isRepeatable`
734
+ - Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
735
+
736
+ The following methods were removed from interfaces. All of these methods are still available in the concrete classes
737
+ that implement them, but you should update your code to use alternative methods:
738
+
739
+ - Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
740
+ `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
741
+ `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or
742
+ `$client->setDefaultOption('headers/{header_name}', 'value')`. or
743
+ `$client->setDefaultOption('headers', array('header_name' => 'value'))`.
744
+ - Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`.
745
+ - Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail.
746
+ - Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail.
747
+ - Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail.
748
+ - Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin.
749
+ - Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin.
750
+ - Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin.
751
+
752
+ ### Cache plugin breaking changes
753
+
754
+ - CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
755
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
756
+ - Always setting X-cache headers on cached responses
757
+ - Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
758
+ - `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
759
+ $request, Response $response);`
760
+ - `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
761
+ - `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
762
+ - Added `CacheStorageInterface::purge($url)`
763
+ - `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
764
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
765
+ CanCacheStrategyInterface $canCache = null)`
766
+ - Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
767
+
768
+ 3.5 to 3.6
769
+ ----------
770
+
771
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
772
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
773
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
774
+ For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader().
775
+ Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request.
776
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
777
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
778
+ CacheControl header implementation.
779
+ * Moved getLinks() from Response to just be used on a Link header object.
780
+
781
+ If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the
782
+ HeaderInterface (e.g. toArray(), getAll(), etc.).
783
+
784
+ ### Interface changes
785
+
786
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
787
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
788
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
789
+ Guzzle\Http\Curl\RequestMediator
790
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
791
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
792
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
793
+
794
+ ### Removed deprecated functions
795
+
796
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
797
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
798
+
799
+ ### Deprecations
800
+
801
+ * The ability to case-insensitively search for header values
802
+ * Guzzle\Http\Message\Header::hasExactHeader
803
+ * Guzzle\Http\Message\Header::raw. Use getAll()
804
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
805
+ instead.
806
+
807
+ ### Other changes
808
+
809
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
810
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
811
+ directly via interfaces
812
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
813
+ but are a no-op until removed.
814
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
815
+ `Guzzle\Service\Command\ArrayCommandInterface`.
816
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
817
+ on a request while the request is still being transferred
818
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
819
+
820
+ 3.3 to 3.4
821
+ ----------
822
+
823
+ Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs.
824
+
825
+ 3.2 to 3.3
826
+ ----------
827
+
828
+ ### Response::getEtag() quote stripping removed
829
+
830
+ `Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header
831
+
832
+ ### Removed `Guzzle\Http\Utils`
833
+
834
+ The `Guzzle\Http\Utils` class was removed. This class was only used for testing.
835
+
836
+ ### Stream wrapper and type
837
+
838
+ `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase.
839
+
840
+ ### curl.emit_io became emit_io
841
+
842
+ Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the
843
+ 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
844
+
845
+ 3.1 to 3.2
846
+ ----------
847
+
848
+ ### CurlMulti is no longer reused globally
849
+
850
+ Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added
851
+ to a single client can pollute requests dispatched from other clients.
852
+
853
+ If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the
854
+ ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is
855
+ created.
856
+
857
+ ```php
858
+ $multi = new Guzzle\Http\Curl\CurlMulti();
859
+ $builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json');
860
+ $builder->addListener('service_builder.create_client', function ($event) use ($multi) {
861
+ $event['client']->setCurlMulti($multi);
862
+ }
863
+ });
864
+ ```
865
+
866
+ ### No default path
867
+
868
+ URLs no longer have a default path value of '/' if no path was specified.
869
+
870
+ Before:
871
+
872
+ ```php
873
+ $request = $client->get('http://www.foo.com');
874
+ echo $request->getUrl();
875
+ // >> http://www.foo.com/
876
+ ```
877
+
878
+ After:
879
+
880
+ ```php
881
+ $request = $client->get('http://www.foo.com');
882
+ echo $request->getUrl();
883
+ // >> http://www.foo.com
884
+ ```
885
+
886
+ ### Less verbose BadResponseException
887
+
888
+ The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and
889
+ response information. You can, however, get access to the request and response object by calling `getRequest()` or
890
+ `getResponse()` on the exception object.
891
+
892
+ ### Query parameter aggregation
893
+
894
+ Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a
895
+ setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is
896
+ responsible for handling the aggregation of multi-valued query string variables into a flattened hash.
897
+
898
+ 2.8 to 3.x
899
+ ----------
900
+
901
+ ### Guzzle\Service\Inspector
902
+
903
+ Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig`
904
+
905
+ **Before**
906
+
907
+ ```php
908
+ use Guzzle\Service\Inspector;
909
+
910
+ class YourClient extends \Guzzle\Service\Client
911
+ {
912
+ public static function factory($config = array())
913
+ {
914
+ $default = array();
915
+ $required = array('base_url', 'username', 'api_key');
916
+ $config = Inspector::fromConfig($config, $default, $required);
917
+
918
+ $client = new self(
919
+ $config->get('base_url'),
920
+ $config->get('username'),
921
+ $config->get('api_key')
922
+ );
923
+ $client->setConfig($config);
924
+
925
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
926
+
927
+ return $client;
928
+ }
929
+ ```
930
+
931
+ **After**
932
+
933
+ ```php
934
+ use Guzzle\Common\Collection;
935
+
936
+ class YourClient extends \Guzzle\Service\Client
937
+ {
938
+ public static function factory($config = array())
939
+ {
940
+ $default = array();
941
+ $required = array('base_url', 'username', 'api_key');
942
+ $config = Collection::fromConfig($config, $default, $required);
943
+
944
+ $client = new self(
945
+ $config->get('base_url'),
946
+ $config->get('username'),
947
+ $config->get('api_key')
948
+ );
949
+ $client->setConfig($config);
950
+
951
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
952
+
953
+ return $client;
954
+ }
955
+ ```
956
+
957
+ ### Convert XML Service Descriptions to JSON
958
+
959
+ **Before**
960
+
961
+ ```xml
962
+ <?xml version="1.0" encoding="UTF-8"?>
963
+ <client>
964
+ <commands>
965
+ <!-- Groups -->
966
+ <command name="list_groups" method="GET" uri="groups.json">
967
+ <doc>Get a list of groups</doc>
968
+ </command>
969
+ <command name="search_groups" method="GET" uri='search.json?query="{{query}} type:group"'>
970
+ <doc>Uses a search query to get a list of groups</doc>
971
+ <param name="query" type="string" required="true" />
972
+ </command>
973
+ <command name="create_group" method="POST" uri="groups.json">
974
+ <doc>Create a group</doc>
975
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
976
+ <param name="Content-Type" location="header" static="application/json"/>
977
+ </command>
978
+ <command name="delete_group" method="DELETE" uri="groups/{{id}}.json">
979
+ <doc>Delete a group by ID</doc>
980
+ <param name="id" type="integer" required="true"/>
981
+ </command>
982
+ <command name="get_group" method="GET" uri="groups/{{id}}.json">
983
+ <param name="id" type="integer" required="true"/>
984
+ </command>
985
+ <command name="update_group" method="PUT" uri="groups/{{id}}.json">
986
+ <doc>Update a group</doc>
987
+ <param name="id" type="integer" required="true"/>
988
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
989
+ <param name="Content-Type" location="header" static="application/json"/>
990
+ </command>
991
+ </commands>
992
+ </client>
993
+ ```
994
+
995
+ **After**
996
+
997
+ ```json
998
+ {
999
+ "name": "Zendesk REST API v2",
1000
+ "apiVersion": "2012-12-31",
1001
+ "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users",
1002
+ "operations": {
1003
+ "list_groups": {
1004
+ "httpMethod":"GET",
1005
+ "uri": "groups.json",
1006
+ "summary": "Get a list of groups"
1007
+ },
1008
+ "search_groups":{
1009
+ "httpMethod":"GET",
1010
+ "uri": "search.json?query=\"{query} type:group\"",
1011
+ "summary": "Uses a search query to get a list of groups",
1012
+ "parameters":{
1013
+ "query":{
1014
+ "location": "uri",
1015
+ "description":"Zendesk Search Query",
1016
+ "type": "string",
1017
+ "required": true
1018
+ }
1019
+ }
1020
+ },
1021
+ "create_group": {
1022
+ "httpMethod":"POST",
1023
+ "uri": "groups.json",
1024
+ "summary": "Create a group",
1025
+ "parameters":{
1026
+ "data": {
1027
+ "type": "array",
1028
+ "location": "body",
1029
+ "description":"Group JSON",
1030
+ "filters": "json_encode",
1031
+ "required": true
1032
+ },
1033
+ "Content-Type":{
1034
+ "type": "string",
1035
+ "location":"header",
1036
+ "static": "application/json"
1037
+ }
1038
+ }
1039
+ },
1040
+ "delete_group": {
1041
+ "httpMethod":"DELETE",
1042
+ "uri": "groups/{id}.json",
1043
+ "summary": "Delete a group",
1044
+ "parameters":{
1045
+ "id":{
1046
+ "location": "uri",
1047
+ "description":"Group to delete by ID",
1048
+ "type": "integer",
1049
+ "required": true
1050
+ }
1051
+ }
1052
+ },
1053
+ "get_group": {
1054
+ "httpMethod":"GET",
1055
+ "uri": "groups/{id}.json",
1056
+ "summary": "Get a ticket",
1057
+ "parameters":{
1058
+ "id":{
1059
+ "location": "uri",
1060
+ "description":"Group to get by ID",
1061
+ "type": "integer",
1062
+ "required": true
1063
+ }
1064
+ }
1065
+ },
1066
+ "update_group": {
1067
+ "httpMethod":"PUT",
1068
+ "uri": "groups/{id}.json",
1069
+ "summary": "Update a group",
1070
+ "parameters":{
1071
+ "id": {
1072
+ "location": "uri",
1073
+ "description":"Group to update by ID",
1074
+ "type": "integer",
1075
+ "required": true
1076
+ },
1077
+ "data": {
1078
+ "type": "array",
1079
+ "location": "body",
1080
+ "description":"Group JSON",
1081
+ "filters": "json_encode",
1082
+ "required": true
1083
+ },
1084
+ "Content-Type":{
1085
+ "type": "string",
1086
+ "location":"header",
1087
+ "static": "application/json"
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ ```
1093
+
1094
+ ### Guzzle\Service\Description\ServiceDescription
1095
+
1096
+ Commands are now called Operations
1097
+
1098
+ **Before**
1099
+
1100
+ ```php
1101
+ use Guzzle\Service\Description\ServiceDescription;
1102
+
1103
+ $sd = new ServiceDescription();
1104
+ $sd->getCommands(); // @returns ApiCommandInterface[]
1105
+ $sd->hasCommand($name);
1106
+ $sd->getCommand($name); // @returns ApiCommandInterface|null
1107
+ $sd->addCommand($command); // @param ApiCommandInterface $command
1108
+ ```
1109
+
1110
+ **After**
1111
+
1112
+ ```php
1113
+ use Guzzle\Service\Description\ServiceDescription;
1114
+
1115
+ $sd = new ServiceDescription();
1116
+ $sd->getOperations(); // @returns OperationInterface[]
1117
+ $sd->hasOperation($name);
1118
+ $sd->getOperation($name); // @returns OperationInterface|null
1119
+ $sd->addOperation($operation); // @param OperationInterface $operation
1120
+ ```
1121
+
1122
+ ### Guzzle\Common\Inflection\Inflector
1123
+
1124
+ Namespace is now `Guzzle\Inflection\Inflector`
1125
+
1126
+ ### Guzzle\Http\Plugin
1127
+
1128
+ Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below.
1129
+
1130
+ ### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log
1131
+
1132
+ Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively.
1133
+
1134
+ **Before**
1135
+
1136
+ ```php
1137
+ use Guzzle\Common\Log\ClosureLogAdapter;
1138
+ use Guzzle\Http\Plugin\LogPlugin;
1139
+
1140
+ /** @var \Guzzle\Http\Client */
1141
+ $client;
1142
+
1143
+ // $verbosity is an integer indicating desired message verbosity level
1144
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE);
1145
+ ```
1146
+
1147
+ **After**
1148
+
1149
+ ```php
1150
+ use Guzzle\Log\ClosureLogAdapter;
1151
+ use Guzzle\Log\MessageFormatter;
1152
+ use Guzzle\Plugin\Log\LogPlugin;
1153
+
1154
+ /** @var \Guzzle\Http\Client */
1155
+ $client;
1156
+
1157
+ // $format is a string indicating desired message format -- @see MessageFormatter
1158
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT);
1159
+ ```
1160
+
1161
+ ### Guzzle\Http\Plugin\CurlAuthPlugin
1162
+
1163
+ Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`.
1164
+
1165
+ ### Guzzle\Http\Plugin\ExponentialBackoffPlugin
1166
+
1167
+ Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes.
1168
+
1169
+ **Before**
1170
+
1171
+ ```php
1172
+ use Guzzle\Http\Plugin\ExponentialBackoffPlugin;
1173
+
1174
+ $backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge(
1175
+ ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429)
1176
+ ));
1177
+
1178
+ $client->addSubscriber($backoffPlugin);
1179
+ ```
1180
+
1181
+ **After**
1182
+
1183
+ ```php
1184
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
1185
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
1186
+
1187
+ // Use convenient factory method instead -- see implementation for ideas of what
1188
+ // you can do with chaining backoff strategies
1189
+ $backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge(
1190
+ HttpBackoffStrategy::getDefaultFailureCodes(), array(429)
1191
+ ));
1192
+ $client->addSubscriber($backoffPlugin);
1193
+ ```
1194
+
1195
+ ### Known Issues
1196
+
1197
+ #### [BUG] Accept-Encoding header behavior changed unintentionally.
1198
+
1199
+ (See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e)
1200
+
1201
+ In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to
1202
+ properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen.
1203
+ See issue #217 for a workaround, or use a version containing the fix.
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/composer.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/guzzle",
3
+ "type": "library",
4
+ "description": "Guzzle is a PHP HTTP client library",
5
+ "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
6
+ "homepage": "http://guzzlephp.org/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Michael Dowling",
11
+ "email": "mtdowling@gmail.com",
12
+ "homepage": "https://github.com/mtdowling"
13
+ }
14
+ ],
15
+ "require": {
16
+ "php": ">=5.5.0",
17
+ "guzzlehttp/psr7": "~1.1",
18
+ "guzzlehttp/promises": "~1.0"
19
+ },
20
+ "require-dev": {
21
+ "ext-curl": "*",
22
+ "phpunit/phpunit": "~4.0",
23
+ "psr/log": "~1.0"
24
+ },
25
+ "autoload": {
26
+ "files": ["src/functions_include.php"],
27
+ "psr-4": {
28
+ "GuzzleHttp\\": "src/"
29
+ }
30
+ },
31
+ "autoload-dev": {
32
+ "psr-4": {
33
+ "GuzzleHttp\\Tests\\": "tests/"
34
+ }
35
+ },
36
+ "extra": {
37
+ "branch-alias": {
38
+ "dev-master": "6.2-dev"
39
+ }
40
+ }
41
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Client.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Cookie\CookieJar;
5
+ use GuzzleHttp\Promise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\UriInterface;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+
11
+ /**
12
+ * @method ResponseInterface get($uri, array $options = [])
13
+ * @method ResponseInterface head($uri, array $options = [])
14
+ * @method ResponseInterface put($uri, array $options = [])
15
+ * @method ResponseInterface post($uri, array $options = [])
16
+ * @method ResponseInterface patch($uri, array $options = [])
17
+ * @method ResponseInterface delete($uri, array $options = [])
18
+ * @method Promise\PromiseInterface getAsync($uri, array $options = [])
19
+ * @method Promise\PromiseInterface headAsync($uri, array $options = [])
20
+ * @method Promise\PromiseInterface putAsync($uri, array $options = [])
21
+ * @method Promise\PromiseInterface postAsync($uri, array $options = [])
22
+ * @method Promise\PromiseInterface patchAsync($uri, array $options = [])
23
+ * @method Promise\PromiseInterface deleteAsync($uri, array $options = [])
24
+ */
25
+ class Client implements ClientInterface
26
+ {
27
+ /** @var array Default request options */
28
+ private $config;
29
+
30
+ /**
31
+ * Clients accept an array of constructor parameters.
32
+ *
33
+ * Here's an example of creating a client using a base_uri and an array of
34
+ * default request options to apply to each request:
35
+ *
36
+ * $client = new Client([
37
+ * 'base_uri' => 'http://www.foo.com/1.0/',
38
+ * 'timeout' => 0,
39
+ * 'allow_redirects' => false,
40
+ * 'proxy' => '192.168.16.1:10'
41
+ * ]);
42
+ *
43
+ * Client configuration settings include the following options:
44
+ *
45
+ * - handler: (callable) Function that transfers HTTP requests over the
46
+ * wire. The function is called with a Psr7\Http\Message\RequestInterface
47
+ * and array of transfer options, and must return a
48
+ * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
49
+ * Psr7\Http\Message\ResponseInterface on success. "handler" is a
50
+ * constructor only option that cannot be overridden in per/request
51
+ * options. If no handler is provided, a default handler will be created
52
+ * that enables all of the request options below by attaching all of the
53
+ * default middleware to the handler.
54
+ * - base_uri: (string|UriInterface) Base URI of the client that is merged
55
+ * into relative URIs. Can be a string or instance of UriInterface.
56
+ * - **: any request option
57
+ *
58
+ * @param array $config Client configuration settings.
59
+ *
60
+ * @see \GuzzleHttp\RequestOptions for a list of available request options.
61
+ */
62
+ public function __construct(array $config = [])
63
+ {
64
+ if (!isset($config['handler'])) {
65
+ $config['handler'] = HandlerStack::create();
66
+ }
67
+
68
+ // Convert the base_uri to a UriInterface
69
+ if (isset($config['base_uri'])) {
70
+ $config['base_uri'] = Psr7\uri_for($config['base_uri']);
71
+ }
72
+
73
+ $this->configureDefaults($config);
74
+ }
75
+
76
+ public function __call($method, $args)
77
+ {
78
+ if (count($args) < 1) {
79
+ throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
80
+ }
81
+
82
+ $uri = $args[0];
83
+ $opts = isset($args[1]) ? $args[1] : [];
84
+
85
+ return substr($method, -5) === 'Async'
86
+ ? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
87
+ : $this->request($method, $uri, $opts);
88
+ }
89
+
90
+ public function sendAsync(RequestInterface $request, array $options = [])
91
+ {
92
+ // Merge the base URI into the request URI if needed.
93
+ $options = $this->prepareDefaults($options);
94
+
95
+ return $this->transfer(
96
+ $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
97
+ $options
98
+ );
99
+ }
100
+
101
+ public function send(RequestInterface $request, array $options = [])
102
+ {
103
+ $options[RequestOptions::SYNCHRONOUS] = true;
104
+ return $this->sendAsync($request, $options)->wait();
105
+ }
106
+
107
+ public function requestAsync($method, $uri = null, array $options = [])
108
+ {
109
+ $options = $this->prepareDefaults($options);
110
+ // Remove request modifying parameter because it can be done up-front.
111
+ $headers = isset($options['headers']) ? $options['headers'] : [];
112
+ $body = isset($options['body']) ? $options['body'] : null;
113
+ $version = isset($options['version']) ? $options['version'] : '1.1';
114
+ // Merge the URI into the base URI.
115
+ $uri = $this->buildUri($uri, $options);
116
+ if (is_array($body)) {
117
+ $this->invalidBody();
118
+ }
119
+ $request = new Psr7\Request($method, $uri, $headers, $body, $version);
120
+ // Remove the option so that they are not doubly-applied.
121
+ unset($options['headers'], $options['body'], $options['version']);
122
+
123
+ return $this->transfer($request, $options);
124
+ }
125
+
126
+ public function request($method, $uri = null, array $options = [])
127
+ {
128
+ $options[RequestOptions::SYNCHRONOUS] = true;
129
+ return $this->requestAsync($method, $uri, $options)->wait();
130
+ }
131
+
132
+ public function getConfig($option = null)
133
+ {
134
+ return $option === null
135
+ ? $this->config
136
+ : (isset($this->config[$option]) ? $this->config[$option] : null);
137
+ }
138
+
139
+ private function buildUri($uri, array $config)
140
+ {
141
+ if (!isset($config['base_uri'])) {
142
+ return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
143
+ }
144
+
145
+ return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
146
+ }
147
+
148
+ /**
149
+ * Configures the default options for a client.
150
+ *
151
+ * @param array $config
152
+ */
153
+ private function configureDefaults(array $config)
154
+ {
155
+ $defaults = [
156
+ 'allow_redirects' => RedirectMiddleware::$defaultSettings,
157
+ 'http_errors' => true,
158
+ 'decode_content' => true,
159
+ 'verify' => true,
160
+ 'cookies' => false
161
+ ];
162
+
163
+ // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
164
+ if ($proxy = getenv('HTTP_PROXY')) {
165
+ $defaults['proxy']['http'] = $proxy;
166
+ }
167
+
168
+ if ($proxy = getenv('HTTPS_PROXY')) {
169
+ $defaults['proxy']['https'] = $proxy;
170
+ }
171
+
172
+ if ($noProxy = getenv('NO_PROXY')) {
173
+ $cleanedNoProxy = str_replace(' ', '', $noProxy);
174
+ $defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
175
+ }
176
+
177
+ $this->config = $config + $defaults;
178
+
179
+ if (!empty($config['cookies']) && $config['cookies'] === true) {
180
+ $this->config['cookies'] = new CookieJar();
181
+ }
182
+
183
+ // Add the default user-agent header.
184
+ if (!isset($this->config['headers'])) {
185
+ $this->config['headers'] = ['User-Agent' => default_user_agent()];
186
+ } else {
187
+ // Add the User-Agent header if one was not already set.
188
+ foreach (array_keys($this->config['headers']) as $name) {
189
+ if (strtolower($name) === 'user-agent') {
190
+ return;
191
+ }
192
+ }
193
+ $this->config['headers']['User-Agent'] = default_user_agent();
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Merges default options into the array.
199
+ *
200
+ * @param array $options Options to modify by reference
201
+ *
202
+ * @return array
203
+ */
204
+ private function prepareDefaults($options)
205
+ {
206
+ $defaults = $this->config;
207
+
208
+ if (!empty($defaults['headers'])) {
209
+ // Default headers are only added if they are not present.
210
+ $defaults['_conditional'] = $defaults['headers'];
211
+ unset($defaults['headers']);
212
+ }
213
+
214
+ // Special handling for headers is required as they are added as
215
+ // conditional headers and as headers passed to a request ctor.
216
+ if (array_key_exists('headers', $options)) {
217
+ // Allows default headers to be unset.
218
+ if ($options['headers'] === null) {
219
+ $defaults['_conditional'] = null;
220
+ unset($options['headers']);
221
+ } elseif (!is_array($options['headers'])) {
222
+ throw new \InvalidArgumentException('headers must be an array');
223
+ }
224
+ }
225
+
226
+ // Shallow merge defaults underneath options.
227
+ $result = $options + $defaults;
228
+
229
+ // Remove null values.
230
+ foreach ($result as $k => $v) {
231
+ if ($v === null) {
232
+ unset($result[$k]);
233
+ }
234
+ }
235
+
236
+ return $result;
237
+ }
238
+
239
+ /**
240
+ * Transfers the given request and applies request options.
241
+ *
242
+ * The URI of the request is not modified and the request options are used
243
+ * as-is without merging in default options.
244
+ *
245
+ * @param RequestInterface $request
246
+ * @param array $options
247
+ *
248
+ * @return Promise\PromiseInterface
249
+ */
250
+ private function transfer(RequestInterface $request, array $options)
251
+ {
252
+ // save_to -> sink
253
+ if (isset($options['save_to'])) {
254
+ $options['sink'] = $options['save_to'];
255
+ unset($options['save_to']);
256
+ }
257
+
258
+ // exceptions -> http_error
259
+ if (isset($options['exceptions'])) {
260
+ $options['http_errors'] = $options['exceptions'];
261
+ unset($options['exceptions']);
262
+ }
263
+
264
+ $request = $this->applyOptions($request, $options);
265
+ $handler = $options['handler'];
266
+
267
+ try {
268
+ return Promise\promise_for($handler($request, $options));
269
+ } catch (\Exception $e) {
270
+ return Promise\rejection_for($e);
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Applies the array of request options to a request.
276
+ *
277
+ * @param RequestInterface $request
278
+ * @param array $options
279
+ *
280
+ * @return RequestInterface
281
+ */
282
+ private function applyOptions(RequestInterface $request, array &$options)
283
+ {
284
+ $modify = [];
285
+
286
+ if (isset($options['form_params'])) {
287
+ if (isset($options['multipart'])) {
288
+ throw new \InvalidArgumentException('You cannot use '
289
+ . 'form_params and multipart at the same time. Use the '
290
+ . 'form_params option if you want to send application/'
291
+ . 'x-www-form-urlencoded requests, and the multipart '
292
+ . 'option to send multipart/form-data requests.');
293
+ }
294
+ $options['body'] = http_build_query($options['form_params'], '', '&');
295
+ unset($options['form_params']);
296
+ $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
297
+ }
298
+
299
+ if (isset($options['multipart'])) {
300
+ $elements = $options['multipart'];
301
+ unset($options['multipart']);
302
+ $options['body'] = new Psr7\MultipartStream($elements);
303
+ }
304
+
305
+ if (!empty($options['decode_content'])
306
+ && $options['decode_content'] !== true
307
+ ) {
308
+ $modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
309
+ }
310
+
311
+ if (isset($options['headers'])) {
312
+ if (isset($modify['set_headers'])) {
313
+ $modify['set_headers'] = $options['headers'] + $modify['set_headers'];
314
+ } else {
315
+ $modify['set_headers'] = $options['headers'];
316
+ }
317
+ unset($options['headers']);
318
+ }
319
+
320
+ if (isset($options['body'])) {
321
+ if (is_array($options['body'])) {
322
+ $this->invalidBody();
323
+ }
324
+ $modify['body'] = Psr7\stream_for($options['body']);
325
+ unset($options['body']);
326
+ }
327
+
328
+ if (!empty($options['auth'])) {
329
+ $value = $options['auth'];
330
+ $type = is_array($value)
331
+ ? (isset($value[2]) ? strtolower($value[2]) : 'basic')
332
+ : $value;
333
+ $config['auth'] = $value;
334
+ switch (strtolower($type)) {
335
+ case 'basic':
336
+ $modify['set_headers']['Authorization'] = 'Basic '
337
+ . base64_encode("$value[0]:$value[1]");
338
+ break;
339
+ case 'digest':
340
+ // @todo: Do not rely on curl
341
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
342
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
343
+ break;
344
+ }
345
+ }
346
+
347
+ if (isset($options['query'])) {
348
+ $value = $options['query'];
349
+ if (is_array($value)) {
350
+ $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
351
+ }
352
+ if (!is_string($value)) {
353
+ throw new \InvalidArgumentException('query must be a string or array');
354
+ }
355
+ $modify['query'] = $value;
356
+ unset($options['query']);
357
+ }
358
+
359
+ if (isset($options['json'])) {
360
+ $jsonStr = \GuzzleHttp\json_encode($options['json']);
361
+ $modify['body'] = Psr7\stream_for($jsonStr);
362
+ $options['_conditional']['Content-Type'] = 'application/json';
363
+ unset($options['json']);
364
+ }
365
+
366
+ $request = Psr7\modify_request($request, $modify);
367
+ if ($request->getBody() instanceof Psr7\MultipartStream) {
368
+ // Use a multipart/form-data POST if a Content-Type is not set.
369
+ $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
370
+ . $request->getBody()->getBoundary();
371
+ }
372
+
373
+ // Merge in conditional headers if they are not present.
374
+ if (isset($options['_conditional'])) {
375
+ // Build up the changes so it's in a single clone of the message.
376
+ $modify = [];
377
+ foreach ($options['_conditional'] as $k => $v) {
378
+ if (!$request->hasHeader($k)) {
379
+ $modify['set_headers'][$k] = $v;
380
+ }
381
+ }
382
+ $request = Psr7\modify_request($request, $modify);
383
+ // Don't pass this internal value along to middleware/handlers.
384
+ unset($options['_conditional']);
385
+ }
386
+
387
+ return $request;
388
+ }
389
+
390
+ private function invalidBody()
391
+ {
392
+ throw new \InvalidArgumentException('Passing in the "body" request '
393
+ . 'option as an array to send a POST request has been deprecated. '
394
+ . 'Please use the "form_params" request option to send a '
395
+ . 'application/x-www-form-urlencoded request, or a the "multipart" '
396
+ . 'request option to send a multipart/form-data request.');
397
+ }
398
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/ClientInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Exception\GuzzleException;
6
+ use Psr\Http\Message\RequestInterface;
7
+ use Psr\Http\Message\ResponseInterface;
8
+ use Psr\Http\Message\UriInterface;
9
+
10
+ /**
11
+ * Client interface for sending HTTP requests.
12
+ */
13
+ interface ClientInterface
14
+ {
15
+ const VERSION = '6.2.0';
16
+
17
+ /**
18
+ * Send an HTTP request.
19
+ *
20
+ * @param RequestInterface $request Request to send
21
+ * @param array $options Request options to apply to the given
22
+ * request and to the transfer.
23
+ *
24
+ * @return ResponseInterface
25
+ * @throws GuzzleException
26
+ */
27
+ public function send(RequestInterface $request, array $options = []);
28
+
29
+ /**
30
+ * Asynchronously send an HTTP request.
31
+ *
32
+ * @param RequestInterface $request Request to send
33
+ * @param array $options Request options to apply to the given
34
+ * request and to the transfer.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ public function sendAsync(RequestInterface $request, array $options = []);
39
+
40
+ /**
41
+ * Create and send an HTTP request.
42
+ *
43
+ * Use an absolute path to override the base path of the client, or a
44
+ * relative path to append to the base path of the client. The URL can
45
+ * contain the query string as well.
46
+ *
47
+ * @param string $method HTTP method.
48
+ * @param string|UriInterface|null $uri URI object or string (default null).
49
+ * @param array $options Request options to apply.
50
+ *
51
+ * @return ResponseInterface
52
+ * @throws GuzzleException
53
+ */
54
+ public function request($method, $uri = null, array $options = []);
55
+
56
+ /**
57
+ * Create and send an asynchronous HTTP request.
58
+ *
59
+ * Use an absolute path to override the base path of the client, or a
60
+ * relative path to append to the base path of the client. The URL can
61
+ * contain the query string as well. Use an array to provide a URL
62
+ * template and additional variables to use in the URL template expansion.
63
+ *
64
+ * @param string $method HTTP method
65
+ * @param string|UriInterface $uri URI object or string.
66
+ * @param array $options Request options to apply.
67
+ *
68
+ * @return PromiseInterface
69
+ */
70
+ public function requestAsync($method, $uri, array $options = []);
71
+
72
+ /**
73
+ * Get a client configuration option.
74
+ *
75
+ * These options include default request options of the client, a "handler"
76
+ * (if utilized by the concrete client), and a "base_uri" if utilized by
77
+ * the concrete client.
78
+ *
79
+ * @param string|null $option The config option to retrieve.
80
+ *
81
+ * @return mixed
82
+ */
83
+ public function getConfig($option = null);
84
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Cookie jar that stores cookies as an array
9
+ */
10
+ class CookieJar implements CookieJarInterface
11
+ {
12
+ /** @var SetCookie[] Loaded cookie data */
13
+ private $cookies = [];
14
+
15
+ /** @var bool */
16
+ private $strictMode;
17
+
18
+ /**
19
+ * @param bool $strictMode Set to true to throw exceptions when invalid
20
+ * cookies are added to the cookie jar.
21
+ * @param array $cookieArray Array of SetCookie objects or a hash of
22
+ * arrays that can be used with the SetCookie
23
+ * constructor
24
+ */
25
+ public function __construct($strictMode = false, $cookieArray = [])
26
+ {
27
+ $this->strictMode = $strictMode;
28
+
29
+ foreach ($cookieArray as $cookie) {
30
+ if (!($cookie instanceof SetCookie)) {
31
+ $cookie = new SetCookie($cookie);
32
+ }
33
+ $this->setCookie($cookie);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Create a new Cookie jar from an associative array and domain.
39
+ *
40
+ * @param array $cookies Cookies to create the jar from
41
+ * @param string $domain Domain to set the cookies to
42
+ *
43
+ * @return self
44
+ */
45
+ public static function fromArray(array $cookies, $domain)
46
+ {
47
+ $cookieJar = new self();
48
+ foreach ($cookies as $name => $value) {
49
+ $cookieJar->setCookie(new SetCookie([
50
+ 'Domain' => $domain,
51
+ 'Name' => $name,
52
+ 'Value' => $value,
53
+ 'Discard' => true
54
+ ]));
55
+ }
56
+
57
+ return $cookieJar;
58
+ }
59
+
60
+ /**
61
+ * @deprecated
62
+ */
63
+ public static function getCookieValue($value)
64
+ {
65
+ return $value;
66
+ }
67
+
68
+ /**
69
+ * Evaluate if this cookie should be persisted to storage
70
+ * that survives between requests.
71
+ *
72
+ * @param SetCookie $cookie Being evaluated.
73
+ * @param bool $allowSessionCookies If we should persist session cookies
74
+ * @return bool
75
+ */
76
+ public static function shouldPersist(
77
+ SetCookie $cookie,
78
+ $allowSessionCookies = false
79
+ ) {
80
+ if ($cookie->getExpires() || $allowSessionCookies) {
81
+ if (!$cookie->getDiscard()) {
82
+ return true;
83
+ }
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ public function toArray()
90
+ {
91
+ return array_map(function (SetCookie $cookie) {
92
+ return $cookie->toArray();
93
+ }, $this->getIterator()->getArrayCopy());
94
+ }
95
+
96
+ public function clear($domain = null, $path = null, $name = null)
97
+ {
98
+ if (!$domain) {
99
+ $this->cookies = [];
100
+ return;
101
+ } elseif (!$path) {
102
+ $this->cookies = array_filter(
103
+ $this->cookies,
104
+ function (SetCookie $cookie) use ($path, $domain) {
105
+ return !$cookie->matchesDomain($domain);
106
+ }
107
+ );
108
+ } elseif (!$name) {
109
+ $this->cookies = array_filter(
110
+ $this->cookies,
111
+ function (SetCookie $cookie) use ($path, $domain) {
112
+ return !($cookie->matchesPath($path) &&
113
+ $cookie->matchesDomain($domain));
114
+ }
115
+ );
116
+ } else {
117
+ $this->cookies = array_filter(
118
+ $this->cookies,
119
+ function (SetCookie $cookie) use ($path, $domain, $name) {
120
+ return !($cookie->getName() == $name &&
121
+ $cookie->matchesPath($path) &&
122
+ $cookie->matchesDomain($domain));
123
+ }
124
+ );
125
+ }
126
+ }
127
+
128
+ public function clearSessionCookies()
129
+ {
130
+ $this->cookies = array_filter(
131
+ $this->cookies,
132
+ function (SetCookie $cookie) {
133
+ return !$cookie->getDiscard() && $cookie->getExpires();
134
+ }
135
+ );
136
+ }
137
+
138
+ public function setCookie(SetCookie $cookie)
139
+ {
140
+ // If the name string is empty (but not 0), ignore the set-cookie
141
+ // string entirely.
142
+ $name = $cookie->getName();
143
+ if (!$name && $name !== '0') {
144
+ return false;
145
+ }
146
+
147
+ // Only allow cookies with set and valid domain, name, value
148
+ $result = $cookie->validate();
149
+ if ($result !== true) {
150
+ if ($this->strictMode) {
151
+ throw new \RuntimeException('Invalid cookie: ' . $result);
152
+ } else {
153
+ $this->removeCookieIfEmpty($cookie);
154
+ return false;
155
+ }
156
+ }
157
+
158
+ // Resolve conflicts with previously set cookies
159
+ foreach ($this->cookies as $i => $c) {
160
+
161
+ // Two cookies are identical, when their path, and domain are
162
+ // identical.
163
+ if ($c->getPath() != $cookie->getPath() ||
164
+ $c->getDomain() != $cookie->getDomain() ||
165
+ $c->getName() != $cookie->getName()
166
+ ) {
167
+ continue;
168
+ }
169
+
170
+ // The previously set cookie is a discard cookie and this one is
171
+ // not so allow the new cookie to be set
172
+ if (!$cookie->getDiscard() && $c->getDiscard()) {
173
+ unset($this->cookies[$i]);
174
+ continue;
175
+ }
176
+
177
+ // If the new cookie's expiration is further into the future, then
178
+ // replace the old cookie
179
+ if ($cookie->getExpires() > $c->getExpires()) {
180
+ unset($this->cookies[$i]);
181
+ continue;
182
+ }
183
+
184
+ // If the value has changed, we better change it
185
+ if ($cookie->getValue() !== $c->getValue()) {
186
+ unset($this->cookies[$i]);
187
+ continue;
188
+ }
189
+
190
+ // The cookie exists, so no need to continue
191
+ return false;
192
+ }
193
+
194
+ $this->cookies[] = $cookie;
195
+
196
+ return true;
197
+ }
198
+
199
+ public function count()
200
+ {
201
+ return count($this->cookies);
202
+ }
203
+
204
+ public function getIterator()
205
+ {
206
+ return new \ArrayIterator(array_values($this->cookies));
207
+ }
208
+
209
+ public function extractCookies(
210
+ RequestInterface $request,
211
+ ResponseInterface $response
212
+ ) {
213
+ if ($cookieHeader = $response->getHeader('Set-Cookie')) {
214
+ foreach ($cookieHeader as $cookie) {
215
+ $sc = SetCookie::fromString($cookie);
216
+ if (!$sc->getDomain()) {
217
+ $sc->setDomain($request->getUri()->getHost());
218
+ }
219
+ $this->setCookie($sc);
220
+ }
221
+ }
222
+ }
223
+
224
+ public function withCookieHeader(RequestInterface $request)
225
+ {
226
+ $values = [];
227
+ $uri = $request->getUri();
228
+ $scheme = $uri->getScheme();
229
+ $host = $uri->getHost();
230
+ $path = $uri->getPath() ?: '/';
231
+
232
+ foreach ($this->cookies as $cookie) {
233
+ if ($cookie->matchesPath($path) &&
234
+ $cookie->matchesDomain($host) &&
235
+ !$cookie->isExpired() &&
236
+ (!$cookie->getSecure() || $scheme == 'https')
237
+ ) {
238
+ $values[] = $cookie->getName() . '='
239
+ . $cookie->getValue();
240
+ }
241
+ }
242
+
243
+ return $values
244
+ ? $request->withHeader('Cookie', implode('; ', $values))
245
+ : $request;
246
+ }
247
+
248
+ /**
249
+ * If a cookie already exists and the server asks to set it again with a
250
+ * null value, the cookie must be deleted.
251
+ *
252
+ * @param SetCookie $cookie
253
+ */
254
+ private function removeCookieIfEmpty(SetCookie $cookie)
255
+ {
256
+ $cookieValue = $cookie->getValue();
257
+ if ($cookieValue === null || $cookieValue === '') {
258
+ $this->clear(
259
+ $cookie->getDomain(),
260
+ $cookie->getPath(),
261
+ $cookie->getName()
262
+ );
263
+ }
264
+ }
265
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Stores HTTP cookies.
9
+ *
10
+ * It extracts cookies from HTTP requests, and returns them in HTTP responses.
11
+ * CookieJarInterface instances automatically expire contained cookies when
12
+ * necessary. Subclasses are also responsible for storing and retrieving
13
+ * cookies from a file, database, etc.
14
+ *
15
+ * @link http://docs.python.org/2/library/cookielib.html Inspiration
16
+ */
17
+ interface CookieJarInterface extends \Countable, \IteratorAggregate
18
+ {
19
+ /**
20
+ * Create a request with added cookie headers.
21
+ *
22
+ * If no matching cookies are found in the cookie jar, then no Cookie
23
+ * header is added to the request and the same request is returned.
24
+ *
25
+ * @param RequestInterface $request Request object to modify.
26
+ *
27
+ * @return RequestInterface returns the modified request.
28
+ */
29
+ public function withCookieHeader(RequestInterface $request);
30
+
31
+ /**
32
+ * Extract cookies from an HTTP response and store them in the CookieJar.
33
+ *
34
+ * @param RequestInterface $request Request that was sent
35
+ * @param ResponseInterface $response Response that was received
36
+ */
37
+ public function extractCookies(
38
+ RequestInterface $request,
39
+ ResponseInterface $response
40
+ );
41
+
42
+ /**
43
+ * Sets a cookie in the cookie jar.
44
+ *
45
+ * @param SetCookie $cookie Cookie to set.
46
+ *
47
+ * @return bool Returns true on success or false on failure
48
+ */
49
+ public function setCookie(SetCookie $cookie);
50
+
51
+ /**
52
+ * Remove cookies currently held in the cookie jar.
53
+ *
54
+ * Invoking this method without arguments will empty the whole cookie jar.
55
+ * If given a $domain argument only cookies belonging to that domain will
56
+ * be removed. If given a $domain and $path argument, cookies belonging to
57
+ * the specified path within that domain are removed. If given all three
58
+ * arguments, then the cookie with the specified name, path and domain is
59
+ * removed.
60
+ *
61
+ * @param string $domain Clears cookies matching a domain
62
+ * @param string $path Clears cookies matching a domain and path
63
+ * @param string $name Clears cookies matching a domain, path, and name
64
+ *
65
+ * @return CookieJarInterface
66
+ */
67
+ public function clear($domain = null, $path = null, $name = null);
68
+
69
+ /**
70
+ * Discard all sessions cookies.
71
+ *
72
+ * Removes cookies that don't have an expire field or a have a discard
73
+ * field set to true. To be called when the user agent shuts down according
74
+ * to RFC 2965.
75
+ */
76
+ public function clearSessionCookies();
77
+
78
+ /**
79
+ * Converts the cookie jar to an array.
80
+ *
81
+ * @return array
82
+ */
83
+ public function toArray();
84
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists non-session cookies using a JSON formatted file
6
+ */
7
+ class FileCookieJar extends CookieJar
8
+ {
9
+ /** @var string filename */
10
+ private $filename;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new FileCookieJar object
17
+ *
18
+ * @param string $cookieFile File to store the cookie data
19
+ * @param bool $storeSessionCookies Set to true to store session cookies
20
+ * in the cookie jar.
21
+ *
22
+ * @throws \RuntimeException if the file cannot be found or created
23
+ */
24
+ public function __construct($cookieFile, $storeSessionCookies = false)
25
+ {
26
+ $this->filename = $cookieFile;
27
+ $this->storeSessionCookies = $storeSessionCookies;
28
+
29
+ if (file_exists($cookieFile)) {
30
+ $this->load($cookieFile);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Saves the file when shutting down
36
+ */
37
+ public function __destruct()
38
+ {
39
+ $this->save($this->filename);
40
+ }
41
+
42
+ /**
43
+ * Saves the cookies to a file.
44
+ *
45
+ * @param string $filename File to save
46
+ * @throws \RuntimeException if the file cannot be found or created
47
+ */
48
+ public function save($filename)
49
+ {
50
+ $json = [];
51
+ foreach ($this as $cookie) {
52
+ /** @var SetCookie $cookie */
53
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
54
+ $json[] = $cookie->toArray();
55
+ }
56
+ }
57
+
58
+ $jsonStr = \GuzzleHttp\json_encode($json);
59
+ if (false === file_put_contents($filename, $jsonStr)) {
60
+ throw new \RuntimeException("Unable to save file {$filename}");
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Load cookies from a JSON formatted file.
66
+ *
67
+ * Old cookies are kept unless overwritten by newly loaded ones.
68
+ *
69
+ * @param string $filename Cookie file to load.
70
+ * @throws \RuntimeException if the file cannot be loaded.
71
+ */
72
+ public function load($filename)
73
+ {
74
+ $json = file_get_contents($filename);
75
+ if (false === $json) {
76
+ throw new \RuntimeException("Unable to load file {$filename}");
77
+ } elseif ($json === '') {
78
+ return;
79
+ }
80
+
81
+ $data = \GuzzleHttp\json_decode($json, true);
82
+ if (is_array($data)) {
83
+ foreach (json_decode($json, true) as $cookie) {
84
+ $this->setCookie(new SetCookie($cookie));
85
+ }
86
+ } elseif (strlen($data)) {
87
+ throw new \RuntimeException("Invalid cookie file: {$filename}");
88
+ }
89
+ }
90
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists cookies in the client session
6
+ */
7
+ class SessionCookieJar extends CookieJar
8
+ {
9
+ /** @var string session key */
10
+ private $sessionKey;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new SessionCookieJar object
17
+ *
18
+ * @param string $sessionKey Session key name to store the cookie
19
+ * data in session
20
+ * @param bool $storeSessionCookies Set to true to store session cookies
21
+ * in the cookie jar.
22
+ */
23
+ public function __construct($sessionKey, $storeSessionCookies = false)
24
+ {
25
+ $this->sessionKey = $sessionKey;
26
+ $this->storeSessionCookies = $storeSessionCookies;
27
+ $this->load();
28
+ }
29
+
30
+ /**
31
+ * Saves cookies to session when shutting down
32
+ */
33
+ public function __destruct()
34
+ {
35
+ $this->save();
36
+ }
37
+
38
+ /**
39
+ * Save cookies to the client session
40
+ */
41
+ public function save()
42
+ {
43
+ $json = [];
44
+ foreach ($this as $cookie) {
45
+ /** @var SetCookie $cookie */
46
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
47
+ $json[] = $cookie->toArray();
48
+ }
49
+ }
50
+
51
+ $_SESSION[$this->sessionKey] = json_encode($json);
52
+ }
53
+
54
+ /**
55
+ * Load the contents of the client session into the data array
56
+ */
57
+ protected function load()
58
+ {
59
+ $cookieJar = isset($_SESSION[$this->sessionKey])
60
+ ? $_SESSION[$this->sessionKey]
61
+ : null;
62
+
63
+ $data = json_decode($cookieJar, true);
64
+ if (is_array($data)) {
65
+ foreach ($data as $cookie) {
66
+ $this->setCookie(new SetCookie($cookie));
67
+ }
68
+ } elseif (strlen($data)) {
69
+ throw new \RuntimeException("Invalid cookie data");
70
+ }
71
+ }
72
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Set-Cookie object
6
+ */
7
+ class SetCookie
8
+ {
9
+ /** @var array */
10
+ private static $defaults = [
11
+ 'Name' => null,
12
+ 'Value' => null,
13
+ 'Domain' => null,
14
+ 'Path' => '/',
15
+ 'Max-Age' => null,
16
+ 'Expires' => null,
17
+ 'Secure' => false,
18
+ 'Discard' => false,
19
+ 'HttpOnly' => false
20
+ ];
21
+
22
+ /** @var array Cookie data */
23
+ private $data;
24
+
25
+ /**
26
+ * Create a new SetCookie object from a string
27
+ *
28
+ * @param string $cookie Set-Cookie header string
29
+ *
30
+ * @return self
31
+ */
32
+ public static function fromString($cookie)
33
+ {
34
+ // Create the default return array
35
+ $data = self::$defaults;
36
+ // Explode the cookie string using a series of semicolons
37
+ $pieces = array_filter(array_map('trim', explode(';', $cookie)));
38
+ // The name of the cookie (first kvp) must include an equal sign.
39
+ if (empty($pieces) || !strpos($pieces[0], '=')) {
40
+ return new self($data);
41
+ }
42
+
43
+ // Add the cookie pieces into the parsed data array
44
+ foreach ($pieces as $part) {
45
+
46
+ $cookieParts = explode('=', $part, 2);
47
+ $key = trim($cookieParts[0]);
48
+ $value = isset($cookieParts[1])
49
+ ? trim($cookieParts[1], " \n\r\t\0\x0B")
50
+ : true;
51
+
52
+ // Only check for non-cookies when cookies have been found
53
+ if (empty($data['Name'])) {
54
+ $data['Name'] = $key;
55
+ $data['Value'] = $value;
56
+ } else {
57
+ foreach (array_keys(self::$defaults) as $search) {
58
+ if (!strcasecmp($search, $key)) {
59
+ $data[$search] = $value;
60
+ continue 2;
61
+ }
62
+ }
63
+ $data[$key] = $value;
64
+ }
65
+ }
66
+
67
+ return new self($data);
68
+ }
69
+
70
+ /**
71
+ * @param array $data Array of cookie data provided by a Cookie parser
72
+ */
73
+ public function __construct(array $data = [])
74
+ {
75
+ $this->data = array_replace(self::$defaults, $data);
76
+ // Extract the Expires value and turn it into a UNIX timestamp if needed
77
+ if (!$this->getExpires() && $this->getMaxAge()) {
78
+ // Calculate the Expires date
79
+ $this->setExpires(time() + $this->getMaxAge());
80
+ } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
81
+ $this->setExpires($this->getExpires());
82
+ }
83
+ }
84
+
85
+ public function __toString()
86
+ {
87
+ $str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
88
+ foreach ($this->data as $k => $v) {
89
+ if ($k != 'Name' && $k != 'Value' && $v !== null && $v !== false) {
90
+ if ($k == 'Expires') {
91
+ $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
92
+ } else {
93
+ $str .= ($v === true ? $k : "{$k}={$v}") . '; ';
94
+ }
95
+ }
96
+ }
97
+
98
+ return rtrim($str, '; ');
99
+ }
100
+
101
+ public function toArray()
102
+ {
103
+ return $this->data;
104
+ }
105
+
106
+ /**
107
+ * Get the cookie name
108
+ *
109
+ * @return string
110
+ */
111
+ public function getName()
112
+ {
113
+ return $this->data['Name'];
114
+ }
115
+
116
+ /**
117
+ * Set the cookie name
118
+ *
119
+ * @param string $name Cookie name
120
+ */
121
+ public function setName($name)
122
+ {
123
+ $this->data['Name'] = $name;
124
+ }
125
+
126
+ /**
127
+ * Get the cookie value
128
+ *
129
+ * @return string
130
+ */
131
+ public function getValue()
132
+ {
133
+ return $this->data['Value'];
134
+ }
135
+
136
+ /**
137
+ * Set the cookie value
138
+ *
139
+ * @param string $value Cookie value
140
+ */
141
+ public function setValue($value)
142
+ {
143
+ $this->data['Value'] = $value;
144
+ }
145
+
146
+ /**
147
+ * Get the domain
148
+ *
149
+ * @return string|null
150
+ */
151
+ public function getDomain()
152
+ {
153
+ return $this->data['Domain'];
154
+ }
155
+
156
+ /**
157
+ * Set the domain of the cookie
158
+ *
159
+ * @param string $domain
160
+ */
161
+ public function setDomain($domain)
162
+ {
163
+ $this->data['Domain'] = $domain;
164
+ }
165
+
166
+ /**
167
+ * Get the path
168
+ *
169
+ * @return string
170
+ */
171
+ public function getPath()
172
+ {
173
+ return $this->data['Path'];
174
+ }
175
+
176
+ /**
177
+ * Set the path of the cookie
178
+ *
179
+ * @param string $path Path of the cookie
180
+ */
181
+ public function setPath($path)
182
+ {
183
+ $this->data['Path'] = $path;
184
+ }
185
+
186
+ /**
187
+ * Maximum lifetime of the cookie in seconds
188
+ *
189
+ * @return int|null
190
+ */
191
+ public function getMaxAge()
192
+ {
193
+ return $this->data['Max-Age'];
194
+ }
195
+
196
+ /**
197
+ * Set the max-age of the cookie
198
+ *
199
+ * @param int $maxAge Max age of the cookie in seconds
200
+ */
201
+ public function setMaxAge($maxAge)
202
+ {
203
+ $this->data['Max-Age'] = $maxAge;
204
+ }
205
+
206
+ /**
207
+ * The UNIX timestamp when the cookie Expires
208
+ *
209
+ * @return mixed
210
+ */
211
+ public function getExpires()
212
+ {
213
+ return $this->data['Expires'];
214
+ }
215
+
216
+ /**
217
+ * Set the unix timestamp for which the cookie will expire
218
+ *
219
+ * @param int $timestamp Unix timestamp
220
+ */
221
+ public function setExpires($timestamp)
222
+ {
223
+ $this->data['Expires'] = is_numeric($timestamp)
224
+ ? (int) $timestamp
225
+ : strtotime($timestamp);
226
+ }
227
+
228
+ /**
229
+ * Get whether or not this is a secure cookie
230
+ *
231
+ * @return null|bool
232
+ */
233
+ public function getSecure()
234
+ {
235
+ return $this->data['Secure'];
236
+ }
237
+
238
+ /**
239
+ * Set whether or not the cookie is secure
240
+ *
241
+ * @param bool $secure Set to true or false if secure
242
+ */
243
+ public function setSecure($secure)
244
+ {
245
+ $this->data['Secure'] = $secure;
246
+ }
247
+
248
+ /**
249
+ * Get whether or not this is a session cookie
250
+ *
251
+ * @return null|bool
252
+ */
253
+ public function getDiscard()
254
+ {
255
+ return $this->data['Discard'];
256
+ }
257
+
258
+ /**
259
+ * Set whether or not this is a session cookie
260
+ *
261
+ * @param bool $discard Set to true or false if this is a session cookie
262
+ */
263
+ public function setDiscard($discard)
264
+ {
265
+ $this->data['Discard'] = $discard;
266
+ }
267
+
268
+ /**
269
+ * Get whether or not this is an HTTP only cookie
270
+ *
271
+ * @return bool
272
+ */
273
+ public function getHttpOnly()
274
+ {
275
+ return $this->data['HttpOnly'];
276
+ }
277
+
278
+ /**
279
+ * Set whether or not this is an HTTP only cookie
280
+ *
281
+ * @param bool $httpOnly Set to true or false if this is HTTP only
282
+ */
283
+ public function setHttpOnly($httpOnly)
284
+ {
285
+ $this->data['HttpOnly'] = $httpOnly;
286
+ }
287
+
288
+ /**
289
+ * Check if the cookie matches a path value.
290
+ *
291
+ * A request-path path-matches a given cookie-path if at least one of
292
+ * the following conditions holds:
293
+ *
294
+ * - The cookie-path and the request-path are identical.
295
+ * - The cookie-path is a prefix of the request-path, and the last
296
+ * character of the cookie-path is %x2F ("/").
297
+ * - The cookie-path is a prefix of the request-path, and the first
298
+ * character of the request-path that is not included in the cookie-
299
+ * path is a %x2F ("/") character.
300
+ *
301
+ * @param string $requestPath Path to check against
302
+ *
303
+ * @return bool
304
+ */
305
+ public function matchesPath($requestPath)
306
+ {
307
+ $cookiePath = $this->getPath();
308
+
309
+ // Match on exact matches or when path is the default empty "/"
310
+ if ($cookiePath == '/' || $cookiePath == $requestPath) {
311
+ return true;
312
+ }
313
+
314
+ // Ensure that the cookie-path is a prefix of the request path.
315
+ if (0 !== strpos($requestPath, $cookiePath)) {
316
+ return false;
317
+ }
318
+
319
+ // Match if the last character of the cookie-path is "/"
320
+ if (substr($cookiePath, -1, 1) == '/') {
321
+ return true;
322
+ }
323
+
324
+ // Match if the first character not included in cookie path is "/"
325
+ return substr($requestPath, strlen($cookiePath), 1) == '/';
326
+ }
327
+
328
+ /**
329
+ * Check if the cookie matches a domain value
330
+ *
331
+ * @param string $domain Domain to check against
332
+ *
333
+ * @return bool
334
+ */
335
+ public function matchesDomain($domain)
336
+ {
337
+ // Remove the leading '.' as per spec in RFC 6265.
338
+ // http://tools.ietf.org/html/rfc6265#section-5.2.3
339
+ $cookieDomain = ltrim($this->getDomain(), '.');
340
+
341
+ // Domain not set or exact match.
342
+ if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
343
+ return true;
344
+ }
345
+
346
+ // Matching the subdomain according to RFC 6265.
347
+ // http://tools.ietf.org/html/rfc6265#section-5.1.3
348
+ if (filter_var($domain, FILTER_VALIDATE_IP)) {
349
+ return false;
350
+ }
351
+
352
+ return (bool) preg_match('/\.' . preg_quote($cookieDomain) . '$/', $domain);
353
+ }
354
+
355
+ /**
356
+ * Check if the cookie is expired
357
+ *
358
+ * @return bool
359
+ */
360
+ public function isExpired()
361
+ {
362
+ return $this->getExpires() && time() > $this->getExpires();
363
+ }
364
+
365
+ /**
366
+ * Check if the cookie is valid according to RFC 6265
367
+ *
368
+ * @return bool|string Returns true if valid or an error message if invalid
369
+ */
370
+ public function validate()
371
+ {
372
+ // Names must not be empty, but can be 0
373
+ $name = $this->getName();
374
+ if (empty($name) && !is_numeric($name)) {
375
+ return 'The cookie name must not be empty';
376
+ }
377
+
378
+ // Check if any of the invalid characters are present in the cookie name
379
+ if (preg_match(
380
+ '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/',
381
+ $name)
382
+ ) {
383
+ return 'Cookie name must not contain invalid characters: ASCII '
384
+ . 'Control characters (0-31;127), space, tab and the '
385
+ . 'following characters: ()<>@,;:\"/?={}';
386
+ }
387
+
388
+ // Value must not be empty, but can be 0
389
+ $value = $this->getValue();
390
+ if (empty($value) && !is_numeric($value)) {
391
+ return 'The cookie value must not be empty';
392
+ }
393
+
394
+ // Domains must not be empty, but can be 0
395
+ // A "0" is not a valid internet domain, but may be used as server name
396
+ // in a private network.
397
+ $domain = $this->getDomain();
398
+ if (empty($domain) && !is_numeric($domain)) {
399
+ return 'The cookie domain must not be empty';
400
+ }
401
+
402
+ return true;
403
+ }
404
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when an HTTP error occurs (4xx or 5xx error)
6
+ */
7
+ class BadResponseException extends RequestException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a client error is encountered (4xx codes)
6
+ */
7
+ class ClientException extends BadResponseException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ /**
7
+ * Exception thrown when a connection cannot be established.
8
+ *
9
+ * Note that no response is present for a ConnectException
10
+ */
11
+ class ConnectException extends RequestException
12
+ {
13
+ public function __construct(
14
+ $message,
15
+ RequestInterface $request,
16
+ \Exception $previous = null,
17
+ array $handlerContext = []
18
+ ) {
19
+ parent::__construct($message, $request, null, $previous, $handlerContext);
20
+ }
21
+
22
+ /**
23
+ * @return null
24
+ */
25
+ public function getResponse()
26
+ {
27
+ return null;
28
+ }
29
+
30
+ /**
31
+ * @return bool
32
+ */
33
+ public function hasResponse()
34
+ {
35
+ return false;
36
+ }
37
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ interface GuzzleException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+ use GuzzleHttp\Promise\PromiseInterface;
7
+
8
+ /**
9
+ * HTTP Request exception
10
+ */
11
+ class RequestException extends TransferException
12
+ {
13
+ /** @var RequestInterface */
14
+ private $request;
15
+
16
+ /** @var ResponseInterface */
17
+ private $response;
18
+
19
+ /** @var array */
20
+ private $handlerContext;
21
+
22
+ public function __construct(
23
+ $message,
24
+ RequestInterface $request,
25
+ ResponseInterface $response = null,
26
+ \Exception $previous = null,
27
+ array $handlerContext = []
28
+ ) {
29
+ // Set the code of the exception if the response is set and not future.
30
+ $code = $response && !($response instanceof PromiseInterface)
31
+ ? $response->getStatusCode()
32
+ : 0;
33
+ parent::__construct($message, $code, $previous);
34
+ $this->request = $request;
35
+ $this->response = $response;
36
+ $this->handlerContext = $handlerContext;
37
+ }
38
+
39
+ /**
40
+ * Wrap non-RequestExceptions with a RequestException
41
+ *
42
+ * @param RequestInterface $request
43
+ * @param \Exception $e
44
+ *
45
+ * @return RequestException
46
+ */
47
+ public static function wrapException(RequestInterface $request, \Exception $e)
48
+ {
49
+ return $e instanceof RequestException
50
+ ? $e
51
+ : new RequestException($e->getMessage(), $request, null, $e);
52
+ }
53
+
54
+ /**
55
+ * Factory method to create a new exception with a normalized error message
56
+ *
57
+ * @param RequestInterface $request Request
58
+ * @param ResponseInterface $response Response received
59
+ * @param \Exception $previous Previous exception
60
+ * @param array $ctx Optional handler context.
61
+ *
62
+ * @return self
63
+ */
64
+ public static function create(
65
+ RequestInterface $request,
66
+ ResponseInterface $response = null,
67
+ \Exception $previous = null,
68
+ array $ctx = []
69
+ ) {
70
+ if (!$response) {
71
+ return new self(
72
+ 'Error completing request',
73
+ $request,
74
+ null,
75
+ $previous,
76
+ $ctx
77
+ );
78
+ }
79
+
80
+ $level = floor($response->getStatusCode() / 100);
81
+ if ($level == '4') {
82
+ $label = 'Client error';
83
+ $className = __NAMESPACE__ . '\\ClientException';
84
+ } elseif ($level == '5') {
85
+ $label = 'Server error';
86
+ $className = __NAMESPACE__ . '\\ServerException';
87
+ } else {
88
+ $label = 'Unsuccessful request';
89
+ $className = __CLASS__;
90
+ }
91
+
92
+ // Server Error: `GET /` resulted in a `404 Not Found` response:
93
+ // <html> ... (truncated)
94
+ $message = sprintf(
95
+ '%s: `%s` resulted in a `%s` response',
96
+ $label,
97
+ $request->getMethod() . ' ' . $request->getUri(),
98
+ $response->getStatusCode() . ' ' . $response->getReasonPhrase()
99
+ );
100
+
101
+ $summary = static::getResponseBodySummary($response);
102
+
103
+ if ($summary !== null) {
104
+ $message .= ":\n{$summary}\n";
105
+ }
106
+
107
+ return new $className($message, $request, $response, $previous, $ctx);
108
+ }
109
+
110
+ /**
111
+ * Get a short summary of the response
112
+ *
113
+ * Will return `null` if the response is not printable.
114
+ *
115
+ * @param ResponseInterface $response
116
+ *
117
+ * @return string|null
118
+ */
119
+ public static function getResponseBodySummary(ResponseInterface $response)
120
+ {
121
+ $body = $response->getBody();
122
+
123
+ if (!$body->isSeekable()) {
124
+ return null;
125
+ }
126
+
127
+ $size = $body->getSize();
128
+ $summary = $body->read(120);
129
+ $body->rewind();
130
+
131
+ if ($size > 120) {
132
+ $summary .= ' (truncated...)';
133
+ }
134
+
135
+ // Matches any printable character, including unicode characters:
136
+ // letters, marks, numbers, punctuation, spacing, and separators.
137
+ if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) {
138
+ return null;
139
+ }
140
+
141
+ return $summary;
142
+ }
143
+
144
+ /**
145
+ * Get the request that caused the exception
146
+ *
147
+ * @return RequestInterface
148
+ */
149
+ public function getRequest()
150
+ {
151
+ return $this->request;
152
+ }
153
+
154
+ /**
155
+ * Get the associated response
156
+ *
157
+ * @return ResponseInterface|null
158
+ */
159
+ public function getResponse()
160
+ {
161
+ return $this->response;
162
+ }
163
+
164
+ /**
165
+ * Check if a response was received
166
+ *
167
+ * @return bool
168
+ */
169
+ public function hasResponse()
170
+ {
171
+ return $this->response !== null;
172
+ }
173
+
174
+ /**
175
+ * Get contextual information about the error from the underlying handler.
176
+ *
177
+ * The contents of this array will vary depending on which handler you are
178
+ * using. It may also be just an empty array. Relying on this data will
179
+ * couple you to a specific handler, but can give more debug information
180
+ * when needed.
181
+ *
182
+ * @return array
183
+ */
184
+ public function getHandlerContext()
185
+ {
186
+ return $this->handlerContext;
187
+ }
188
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Exception thrown when a seek fails on a stream.
8
+ */
9
+ class SeekException extends \RuntimeException implements GuzzleException
10
+ {
11
+ private $stream;
12
+
13
+ public function __construct(StreamInterface $stream, $pos = 0, $msg = '')
14
+ {
15
+ $this->stream = $stream;
16
+ $msg = $msg ?: 'Could not seek the stream to position ' . $pos;
17
+ parent::__construct($msg);
18
+ }
19
+
20
+ /**
21
+ * @return StreamInterface
22
+ */
23
+ public function getStream()
24
+ {
25
+ return $this->stream;
26
+ }
27
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a server error is encountered (5xx codes)
6
+ */
7
+ class ServerException extends BadResponseException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TooManyRedirectsException extends RequestException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TransferException extends \RuntimeException implements GuzzleException {}
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Exception\RequestException;
5
+ use GuzzleHttp\Exception\ConnectException;
6
+ use GuzzleHttp\Promise\FulfilledPromise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Psr7;
9
+ use GuzzleHttp\Psr7\LazyOpenStream;
10
+ use GuzzleHttp\TransferStats;
11
+ use Psr\Http\Message\RequestInterface;
12
+
13
+ /**
14
+ * Creates curl resources from a request
15
+ */
16
+ class CurlFactory implements CurlFactoryInterface
17
+ {
18
+ /** @var array */
19
+ private $handles;
20
+
21
+ /** @var int Total number of idle handles to keep in cache */
22
+ private $maxHandles;
23
+
24
+ /**
25
+ * @param int $maxHandles Maximum number of idle handles.
26
+ */
27
+ public function __construct($maxHandles)
28
+ {
29
+ $this->maxHandles = $maxHandles;
30
+ }
31
+
32
+ public function create(RequestInterface $request, array $options)
33
+ {
34
+ if (isset($options['curl']['body_as_string'])) {
35
+ $options['_body_as_string'] = $options['curl']['body_as_string'];
36
+ unset($options['curl']['body_as_string']);
37
+ }
38
+
39
+ $easy = new EasyHandle;
40
+ $easy->request = $request;
41
+ $easy->options = $options;
42
+ $conf = $this->getDefaultConf($easy);
43
+ $this->applyMethod($easy, $conf);
44
+ $this->applyHandlerOptions($easy, $conf);
45
+ $this->applyHeaders($easy, $conf);
46
+ unset($conf['_headers']);
47
+
48
+ // Add handler options from the request configuration options
49
+ if (isset($options['curl'])) {
50
+ $conf = array_replace($conf, $options['curl']);
51
+ }
52
+
53
+ $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
54
+ $easy->handle = $this->handles
55
+ ? array_pop($this->handles)
56
+ : curl_init();
57
+ curl_setopt_array($easy->handle, $conf);
58
+
59
+ return $easy;
60
+ }
61
+
62
+ public function release(EasyHandle $easy)
63
+ {
64
+ $resource = $easy->handle;
65
+ unset($easy->handle);
66
+
67
+ if (count($this->handles) >= $this->maxHandles) {
68
+ curl_close($resource);
69
+ } else {
70
+ // Remove all callback functions as they can hold onto references
71
+ // and are not cleaned up by curl_reset. Using curl_setopt_array
72
+ // does not work for some reason, so removing each one
73
+ // individually.
74
+ curl_setopt($resource, CURLOPT_HEADERFUNCTION, null);
75
+ curl_setopt($resource, CURLOPT_READFUNCTION, null);
76
+ curl_setopt($resource, CURLOPT_WRITEFUNCTION, null);
77
+ curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null);
78
+ curl_reset($resource);
79
+ $this->handles[] = $resource;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Completes a cURL transaction, either returning a response promise or a
85
+ * rejected promise.
86
+ *
87
+ * @param callable $handler
88
+ * @param EasyHandle $easy
89
+ * @param CurlFactoryInterface $factory Dictates how the handle is released
90
+ *
91
+ * @return \GuzzleHttp\Promise\PromiseInterface
92
+ */
93
+ public static function finish(
94
+ callable $handler,
95
+ EasyHandle $easy,
96
+ CurlFactoryInterface $factory
97
+ ) {
98
+ if (isset($easy->options['on_stats'])) {
99
+ self::invokeStats($easy);
100
+ }
101
+
102
+ if (!$easy->response || $easy->errno) {
103
+ return self::finishError($handler, $easy, $factory);
104
+ }
105
+
106
+ // Return the response if it is present and there is no error.
107
+ $factory->release($easy);
108
+
109
+ // Rewind the body of the response if possible.
110
+ $body = $easy->response->getBody();
111
+ if ($body->isSeekable()) {
112
+ $body->rewind();
113
+ }
114
+
115
+ return new FulfilledPromise($easy->response);
116
+ }
117
+
118
+ private static function invokeStats(EasyHandle $easy)
119
+ {
120
+ $curlStats = curl_getinfo($easy->handle);
121
+ $stats = new TransferStats(
122
+ $easy->request,
123
+ $easy->response,
124
+ $curlStats['total_time'],
125
+ $easy->errno,
126
+ $curlStats
127
+ );
128
+ call_user_func($easy->options['on_stats'], $stats);
129
+ }
130
+
131
+ private static function finishError(
132
+ callable $handler,
133
+ EasyHandle $easy,
134
+ CurlFactoryInterface $factory
135
+ ) {
136
+ // Get error information and release the handle to the factory.
137
+ $ctx = [
138
+ 'errno' => $easy->errno,
139
+ 'error' => curl_error($easy->handle),
140
+ ] + curl_getinfo($easy->handle);
141
+ $factory->release($easy);
142
+
143
+ // Retry when nothing is present or when curl failed to rewind.
144
+ if (empty($easy->options['_err_message'])
145
+ && (!$easy->errno || $easy->errno == 65)
146
+ ) {
147
+ return self::retryFailedRewind($handler, $easy, $ctx);
148
+ }
149
+
150
+ return self::createRejection($easy, $ctx);
151
+ }
152
+
153
+ private static function createRejection(EasyHandle $easy, array $ctx)
154
+ {
155
+ static $connectionErrors = [
156
+ CURLE_OPERATION_TIMEOUTED => true,
157
+ CURLE_COULDNT_RESOLVE_HOST => true,
158
+ CURLE_COULDNT_CONNECT => true,
159
+ CURLE_SSL_CONNECT_ERROR => true,
160
+ CURLE_GOT_NOTHING => true,
161
+ ];
162
+
163
+ // If an exception was encountered during the onHeaders event, then
164
+ // return a rejected promise that wraps that exception.
165
+ if ($easy->onHeadersException) {
166
+ return new RejectedPromise(
167
+ new RequestException(
168
+ 'An error was encountered during the on_headers event',
169
+ $easy->request,
170
+ $easy->response,
171
+ $easy->onHeadersException,
172
+ $ctx
173
+ )
174
+ );
175
+ }
176
+
177
+ $message = sprintf(
178
+ 'cURL error %s: %s (%s)',
179
+ $ctx['errno'],
180
+ $ctx['error'],
181
+ 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html'
182
+ );
183
+
184
+ // Create a connection exception if it was a specific error code.
185
+ $error = isset($connectionErrors[$easy->errno])
186
+ ? new ConnectException($message, $easy->request, null, $ctx)
187
+ : new RequestException($message, $easy->request, $easy->response, null, $ctx);
188
+
189
+ return new RejectedPromise($error);
190
+ }
191
+
192
+ private function getDefaultConf(EasyHandle $easy)
193
+ {
194
+ $conf = [
195
+ '_headers' => $easy->request->getHeaders(),
196
+ CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
197
+ CURLOPT_URL => (string) $easy->request->getUri(),
198
+ CURLOPT_RETURNTRANSFER => false,
199
+ CURLOPT_HEADER => false,
200
+ CURLOPT_CONNECTTIMEOUT => 150,
201
+ ];
202
+
203
+ if (defined('CURLOPT_PROTOCOLS')) {
204
+ $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
205
+ }
206
+
207
+ $version = $easy->request->getProtocolVersion();
208
+ if ($version == 1.1) {
209
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
210
+ } elseif ($version == 2.0) {
211
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
212
+ } else {
213
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
214
+ }
215
+
216
+ return $conf;
217
+ }
218
+
219
+ private function applyMethod(EasyHandle $easy, array &$conf)
220
+ {
221
+ $body = $easy->request->getBody();
222
+ $size = $body->getSize();
223
+
224
+ if ($size === null || $size > 0) {
225
+ $this->applyBody($easy->request, $easy->options, $conf);
226
+ return;
227
+ }
228
+
229
+ $method = $easy->request->getMethod();
230
+ if ($method === 'PUT' || $method === 'POST') {
231
+ // See http://tools.ietf.org/html/rfc7230#section-3.3.2
232
+ if (!$easy->request->hasHeader('Content-Length')) {
233
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
234
+ }
235
+ } elseif ($method === 'HEAD') {
236
+ $conf[CURLOPT_NOBODY] = true;
237
+ unset(
238
+ $conf[CURLOPT_WRITEFUNCTION],
239
+ $conf[CURLOPT_READFUNCTION],
240
+ $conf[CURLOPT_FILE],
241
+ $conf[CURLOPT_INFILE]
242
+ );
243
+ }
244
+ }
245
+
246
+ private function applyBody(RequestInterface $request, array $options, array &$conf)
247
+ {
248
+ $size = $request->hasHeader('Content-Length')
249
+ ? (int) $request->getHeaderLine('Content-Length')
250
+ : null;
251
+
252
+ // Send the body as a string if the size is less than 1MB OR if the
253
+ // [curl][body_as_string] request value is set.
254
+ if (($size !== null && $size < 1000000) ||
255
+ !empty($options['_body_as_string'])
256
+ ) {
257
+ $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody();
258
+ // Don't duplicate the Content-Length header
259
+ $this->removeHeader('Content-Length', $conf);
260
+ $this->removeHeader('Transfer-Encoding', $conf);
261
+ } else {
262
+ $conf[CURLOPT_UPLOAD] = true;
263
+ if ($size !== null) {
264
+ $conf[CURLOPT_INFILESIZE] = $size;
265
+ $this->removeHeader('Content-Length', $conf);
266
+ }
267
+ $body = $request->getBody();
268
+ if ($body->isSeekable()) {
269
+ $body->rewind();
270
+ }
271
+ $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
272
+ return $body->read($length);
273
+ };
274
+ }
275
+
276
+ // If the Expect header is not present, prevent curl from adding it
277
+ if (!$request->hasHeader('Expect')) {
278
+ $conf[CURLOPT_HTTPHEADER][] = 'Expect:';
279
+ }
280
+
281
+ // cURL sometimes adds a content-type by default. Prevent this.
282
+ if (!$request->hasHeader('Content-Type')) {
283
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:';
284
+ }
285
+ }
286
+
287
+ private function applyHeaders(EasyHandle $easy, array &$conf)
288
+ {
289
+ foreach ($conf['_headers'] as $name => $values) {
290
+ foreach ($values as $value) {
291
+ $conf[CURLOPT_HTTPHEADER][] = "$name: $value";
292
+ }
293
+ }
294
+
295
+ // Remove the Accept header if one was not set
296
+ if (!$easy->request->hasHeader('Accept')) {
297
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept:';
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Remove a header from the options array.
303
+ *
304
+ * @param string $name Case-insensitive header to remove
305
+ * @param array $options Array of options to modify
306
+ */
307
+ private function removeHeader($name, array &$options)
308
+ {
309
+ foreach (array_keys($options['_headers']) as $key) {
310
+ if (!strcasecmp($key, $name)) {
311
+ unset($options['_headers'][$key]);
312
+ return;
313
+ }
314
+ }
315
+ }
316
+
317
+ private function applyHandlerOptions(EasyHandle $easy, array &$conf)
318
+ {
319
+ $options = $easy->options;
320
+ if (isset($options['verify'])) {
321
+ if ($options['verify'] === false) {
322
+ unset($conf[CURLOPT_CAINFO]);
323
+ $conf[CURLOPT_SSL_VERIFYHOST] = 0;
324
+ $conf[CURLOPT_SSL_VERIFYPEER] = false;
325
+ } else {
326
+ $conf[CURLOPT_SSL_VERIFYHOST] = 2;
327
+ $conf[CURLOPT_SSL_VERIFYPEER] = true;
328
+ if (is_string($options['verify'])) {
329
+ $conf[CURLOPT_CAINFO] = $options['verify'];
330
+ if (!file_exists($options['verify'])) {
331
+ throw new \InvalidArgumentException(
332
+ "SSL CA bundle not found: {$options['verify']}"
333
+ );
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ if (!empty($options['decode_content'])) {
340
+ $accept = $easy->request->getHeaderLine('Accept-Encoding');
341
+ if ($accept) {
342
+ $conf[CURLOPT_ENCODING] = $accept;
343
+ } else {
344
+ $conf[CURLOPT_ENCODING] = '';
345
+ // Don't let curl send the header over the wire
346
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
347
+ }
348
+ }
349
+
350
+ if (isset($options['sink'])) {
351
+ $sink = $options['sink'];
352
+ if (!is_string($sink)) {
353
+ $sink = \GuzzleHttp\Psr7\stream_for($sink);
354
+ } elseif (!is_dir(dirname($sink))) {
355
+ // Ensure that the directory exists before failing in curl.
356
+ throw new \RuntimeException(sprintf(
357
+ 'Directory %s does not exist for sink value of %s',
358
+ dirname($sink),
359
+ $sink
360
+ ));
361
+ } else {
362
+ $sink = new LazyOpenStream($sink, 'w+');
363
+ }
364
+ $easy->sink = $sink;
365
+ $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) {
366
+ return $sink->write($write);
367
+ };
368
+ } else {
369
+ // Use a default temp stream if no sink was set.
370
+ $conf[CURLOPT_FILE] = fopen('php://temp', 'w+');
371
+ $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]);
372
+ }
373
+
374
+ if (isset($options['timeout'])) {
375
+ $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
376
+ }
377
+
378
+ if (isset($options['connect_timeout'])) {
379
+ $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
380
+ }
381
+
382
+ if (isset($options['proxy'])) {
383
+ if (!is_array($options['proxy'])) {
384
+ $conf[CURLOPT_PROXY] = $options['proxy'];
385
+ } else {
386
+ $scheme = $easy->request->getUri()->getScheme();
387
+ if (isset($options['proxy'][$scheme])) {
388
+ $host = $easy->request->getUri()->getHost();
389
+ if (!isset($options['proxy']['no']) ||
390
+ !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])
391
+ ) {
392
+ $conf[CURLOPT_PROXY] = $options['proxy'][$scheme];
393
+ }
394
+ }
395
+ }
396
+ }
397
+
398
+ if (isset($options['cert'])) {
399
+ $cert = $options['cert'];
400
+ if (is_array($cert)) {
401
+ $conf[CURLOPT_SSLCERTPASSWD] = $cert[1];
402
+ $cert = $cert[0];
403
+ }
404
+ if (!file_exists($cert)) {
405
+ throw new \InvalidArgumentException(
406
+ "SSL certificate not found: {$cert}"
407
+ );
408
+ }
409
+ $conf[CURLOPT_SSLCERT] = $cert;
410
+ }
411
+
412
+ if (isset($options['ssl_key'])) {
413
+ $sslKey = $options['ssl_key'];
414
+ if (is_array($sslKey)) {
415
+ $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1];
416
+ $sslKey = $sslKey[0];
417
+ }
418
+ if (!file_exists($sslKey)) {
419
+ throw new \InvalidArgumentException(
420
+ "SSL private key not found: {$sslKey}"
421
+ );
422
+ }
423
+ $conf[CURLOPT_SSLKEY] = $sslKey;
424
+ }
425
+
426
+ if (isset($options['progress'])) {
427
+ $progress = $options['progress'];
428
+ if (!is_callable($progress)) {
429
+ throw new \InvalidArgumentException(
430
+ 'progress client option must be callable'
431
+ );
432
+ }
433
+ $conf[CURLOPT_NOPROGRESS] = false;
434
+ $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) {
435
+ $args = func_get_args();
436
+ // PHP 5.5 pushed the handle onto the start of the args
437
+ if (is_resource($args[0])) {
438
+ array_shift($args);
439
+ }
440
+ call_user_func_array($progress, $args);
441
+ };
442
+ }
443
+
444
+ if (!empty($options['debug'])) {
445
+ $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']);
446
+ $conf[CURLOPT_VERBOSE] = true;
447
+ }
448
+ }
449
+
450
+ /**
451
+ * This function ensures that a response was set on a transaction. If one
452
+ * was not set, then the request is retried if possible. This error
453
+ * typically means you are sending a payload, curl encountered a
454
+ * "Connection died, retrying a fresh connect" error, tried to rewind the
455
+ * stream, and then encountered a "necessary data rewind wasn't possible"
456
+ * error, causing the request to be sent through curl_multi_info_read()
457
+ * without an error status.
458
+ */
459
+ private static function retryFailedRewind(
460
+ callable $handler,
461
+ EasyHandle $easy,
462
+ array $ctx
463
+ ) {
464
+ try {
465
+ // Only rewind if the body has been read from.
466
+ $body = $easy->request->getBody();
467
+ if ($body->tell() > 0) {
468
+ $body->rewind();
469
+ }
470
+ } catch (\RuntimeException $e) {
471
+ $ctx['error'] = 'The connection unexpectedly failed without '
472
+ . 'providing an error. The request would have been retried, '
473
+ . 'but attempting to rewind the request body failed. '
474
+ . 'Exception: ' . $e;
475
+ return self::createRejection($easy, $ctx);
476
+ }
477
+
478
+ // Retry no more than 3 times before giving up.
479
+ if (!isset($easy->options['_curl_retries'])) {
480
+ $easy->options['_curl_retries'] = 1;
481
+ } elseif ($easy->options['_curl_retries'] == 2) {
482
+ $ctx['error'] = 'The cURL request was retried 3 times '
483
+ . 'and did not succeed. The most likely reason for the failure '
484
+ . 'is that cURL was unable to rewind the body of the request '
485
+ . 'and subsequent retries resulted in the same error. Turn on '
486
+ . 'the debug option to see what went wrong. See '
487
+ . 'https://bugs.php.net/bug.php?id=47204 for more information.';
488
+ return self::createRejection($easy, $ctx);
489
+ } else {
490
+ $easy->options['_curl_retries']++;
491
+ }
492
+
493
+ return $handler($easy->request, $easy->options);
494
+ }
495
+
496
+ private function createHeaderFn(EasyHandle $easy)
497
+ {
498
+ if (!isset($easy->options['on_headers'])) {
499
+ $onHeaders = null;
500
+ } elseif (!is_callable($easy->options['on_headers'])) {
501
+ throw new \InvalidArgumentException('on_headers must be callable');
502
+ } else {
503
+ $onHeaders = $easy->options['on_headers'];
504
+ }
505
+
506
+ return function ($ch, $h) use (
507
+ $onHeaders,
508
+ $easy,
509
+ &$startingResponse
510
+ ) {
511
+ $value = trim($h);
512
+ if ($value === '') {
513
+ $startingResponse = true;
514
+ $easy->createResponse();
515
+ if ($onHeaders) {
516
+ try {
517
+ $onHeaders($easy->response);
518
+ } catch (\Exception $e) {
519
+ // Associate the exception with the handle and trigger
520
+ // a curl header write error by returning 0.
521
+ $easy->onHeadersException = $e;
522
+ return -1;
523
+ }
524
+ }
525
+ } elseif ($startingResponse) {
526
+ $startingResponse = false;
527
+ $easy->headers = [$value];
528
+ } else {
529
+ $easy->headers[] = $value;
530
+ }
531
+ return strlen($h);
532
+ };
533
+ }
534
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ interface CurlFactoryInterface
7
+ {
8
+ /**
9
+ * Creates a cURL handle resource.
10
+ *
11
+ * @param RequestInterface $request Request
12
+ * @param array $options Transfer options
13
+ *
14
+ * @return EasyHandle
15
+ * @throws \RuntimeException when an option cannot be applied
16
+ */
17
+ public function create(RequestInterface $request, array $options);
18
+
19
+ /**
20
+ * Release an easy handle, allowing it to be reused or closed.
21
+ *
22
+ * This function must call unset on the easy handle's "handle" property.
23
+ *
24
+ * @param EasyHandle $easy
25
+ */
26
+ public function release(EasyHandle $easy);
27
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use Psr\Http\Message\RequestInterface;
6
+
7
+ /**
8
+ * HTTP handler that uses cURL easy handles as a transport layer.
9
+ *
10
+ * When using the CurlHandler, custom curl options can be specified as an
11
+ * associative array of curl option constants mapping to values in the
12
+ * **curl** key of the "client" key of the request.
13
+ */
14
+ class CurlHandler
15
+ {
16
+ /** @var CurlFactoryInterface */
17
+ private $factory;
18
+
19
+ /**
20
+ * Accepts an associative array of options:
21
+ *
22
+ * - factory: Optional curl factory used to create cURL handles.
23
+ *
24
+ * @param array $options Array of options to use with the handler
25
+ */
26
+ public function __construct(array $options = [])
27
+ {
28
+ $this->factory = isset($options['handle_factory'])
29
+ ? $options['handle_factory']
30
+ : new CurlFactory(3);
31
+ }
32
+
33
+ public function __invoke(RequestInterface $request, array $options)
34
+ {
35
+ if (isset($options['delay'])) {
36
+ usleep($options['delay'] * 1000);
37
+ }
38
+
39
+ $easy = $this->factory->create($request, $options);
40
+ curl_exec($easy->handle);
41
+ $easy->errno = curl_errno($easy->handle);
42
+
43
+ return CurlFactory::finish($this, $easy, $this->factory);
44
+ }
45
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Promise as P;
5
+ use GuzzleHttp\Promise\Promise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\RequestInterface;
8
+
9
+ /**
10
+ * Returns an asynchronous response using curl_multi_* functions.
11
+ *
12
+ * When using the CurlMultiHandler, custom curl options can be specified as an
13
+ * associative array of curl option constants mapping to values in the
14
+ * **curl** key of the provided request options.
15
+ *
16
+ * @property resource $_mh Internal use only. Lazy loaded multi-handle.
17
+ */
18
+ class CurlMultiHandler
19
+ {
20
+ /** @var CurlFactoryInterface */
21
+ private $factory;
22
+ private $selectTimeout;
23
+ private $active;
24
+ private $handles = [];
25
+ private $delays = [];
26
+
27
+ /**
28
+ * This handler accepts the following options:
29
+ *
30
+ * - handle_factory: An optional factory used to create curl handles
31
+ * - select_timeout: Optional timeout (in seconds) to block before timing
32
+ * out while selecting curl handles. Defaults to 1 second.
33
+ *
34
+ * @param array $options
35
+ */
36
+ public function __construct(array $options = [])
37
+ {
38
+ $this->factory = isset($options['handle_factory'])
39
+ ? $options['handle_factory'] : new CurlFactory(50);
40
+ $this->selectTimeout = isset($options['select_timeout'])
41
+ ? $options['select_timeout'] : 1;
42
+ }
43
+
44
+ public function __get($name)
45
+ {
46
+ if ($name === '_mh') {
47
+ return $this->_mh = curl_multi_init();
48
+ }
49
+
50
+ throw new \BadMethodCallException();
51
+ }
52
+
53
+ public function __destruct()
54
+ {
55
+ if (isset($this->_mh)) {
56
+ curl_multi_close($this->_mh);
57
+ unset($this->_mh);
58
+ }
59
+ }
60
+
61
+ public function __invoke(RequestInterface $request, array $options)
62
+ {
63
+ $easy = $this->factory->create($request, $options);
64
+ $id = (int) $easy->handle;
65
+
66
+ $promise = new Promise(
67
+ [$this, 'execute'],
68
+ function () use ($id) { return $this->cancel($id); }
69
+ );
70
+
71
+ $this->addRequest(['easy' => $easy, 'deferred' => $promise]);
72
+
73
+ return $promise;
74
+ }
75
+
76
+ /**
77
+ * Ticks the curl event loop.
78
+ */
79
+ public function tick()
80
+ {
81
+ // Add any delayed handles if needed.
82
+ if ($this->delays) {
83
+ $currentTime = microtime(true);
84
+ foreach ($this->delays as $id => $delay) {
85
+ if ($currentTime >= $delay) {
86
+ unset($this->delays[$id]);
87
+ curl_multi_add_handle(
88
+ $this->_mh,
89
+ $this->handles[$id]['easy']->handle
90
+ );
91
+ }
92
+ }
93
+ }
94
+
95
+ // Step through the task queue which may add additional requests.
96
+ P\queue()->run();
97
+
98
+ if ($this->active &&
99
+ curl_multi_select($this->_mh, $this->selectTimeout) === -1
100
+ ) {
101
+ // Perform a usleep if a select returns -1.
102
+ // See: https://bugs.php.net/bug.php?id=61141
103
+ usleep(250);
104
+ }
105
+
106
+ while (curl_multi_exec($this->_mh, $this->active) === CURLM_CALL_MULTI_PERFORM);
107
+
108
+ $this->processMessages();
109
+ }
110
+
111
+ /**
112
+ * Runs until all outstanding connections have completed.
113
+ */
114
+ public function execute()
115
+ {
116
+ $queue = P\queue();
117
+
118
+ while ($this->handles || !$queue->isEmpty()) {
119
+ // If there are no transfers, then sleep for the next delay
120
+ if (!$this->active && $this->delays) {
121
+ usleep($this->timeToNext());
122
+ }
123
+ $this->tick();
124
+ }
125
+ }
126
+
127
+ private function addRequest(array $entry)
128
+ {
129
+ $easy = $entry['easy'];
130
+ $id = (int) $easy->handle;
131
+ $this->handles[$id] = $entry;
132
+ if (empty($easy->options['delay'])) {
133
+ curl_multi_add_handle($this->_mh, $easy->handle);
134
+ } else {
135
+ $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Cancels a handle from sending and removes references to it.
141
+ *
142
+ * @param int $id Handle ID to cancel and remove.
143
+ *
144
+ * @return bool True on success, false on failure.
145
+ */
146
+ private function cancel($id)
147
+ {
148
+ // Cannot cancel if it has been processed.
149
+ if (!isset($this->handles[$id])) {
150
+ return false;
151
+ }
152
+
153
+ $handle = $this->handles[$id]['easy']->handle;
154
+ unset($this->delays[$id], $this->handles[$id]);
155
+ curl_multi_remove_handle($this->_mh, $handle);
156
+ curl_close($handle);
157
+
158
+ return true;
159
+ }
160
+
161
+ private function processMessages()
162
+ {
163
+ while ($done = curl_multi_info_read($this->_mh)) {
164
+ $id = (int) $done['handle'];
165
+ curl_multi_remove_handle($this->_mh, $done['handle']);
166
+
167
+ if (!isset($this->handles[$id])) {
168
+ // Probably was cancelled.
169
+ continue;
170
+ }
171
+
172
+ $entry = $this->handles[$id];
173
+ unset($this->handles[$id], $this->delays[$id]);
174
+ $entry['easy']->errno = $done['result'];
175
+ $entry['deferred']->resolve(
176
+ CurlFactory::finish(
177
+ $this,
178
+ $entry['easy'],
179
+ $this->factory
180
+ )
181
+ );
182
+ }
183
+ }
184
+
185
+ private function timeToNext()
186
+ {
187
+ $currentTime = microtime(true);
188
+ $nextTime = PHP_INT_MAX;
189
+ foreach ($this->delays as $time) {
190
+ if ($time < $nextTime) {
191
+ $nextTime = $time;
192
+ }
193
+ }
194
+
195
+ return max(0, $nextTime - $currentTime) * 1000000;
196
+ }
197
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Psr7\Response;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+ use Psr\Http\Message\StreamInterface;
8
+
9
+ /**
10
+ * Represents a cURL easy handle and the data it populates.
11
+ *
12
+ * @internal
13
+ */
14
+ final class EasyHandle
15
+ {
16
+ /** @var resource cURL resource */
17
+ public $handle;
18
+
19
+ /** @var StreamInterface Where data is being written */
20
+ public $sink;
21
+
22
+ /** @var array Received HTTP headers so far */
23
+ public $headers = [];
24
+
25
+ /** @var ResponseInterface Received response (if any) */
26
+ public $response;
27
+
28
+ /** @var RequestInterface Request being sent */
29
+ public $request;
30
+
31
+ /** @var array Request options */
32
+ public $options = [];
33
+
34
+ /** @var int cURL error number (if any) */
35
+ public $errno = 0;
36
+
37
+ /** @var \Exception Exception during on_headers (if any) */
38
+ public $onHeadersException;
39
+
40
+ /**
41
+ * Attach a response to the easy handle based on the received headers.
42
+ *
43
+ * @throws \RuntimeException if no headers have been received.
44
+ */
45
+ public function createResponse()
46
+ {
47
+ if (empty($this->headers)) {
48
+ throw new \RuntimeException('No headers have been received');
49
+ }
50
+
51
+ // HTTP-version SP status-code SP reason-phrase
52
+ $startLine = explode(' ', array_shift($this->headers), 3);
53
+ $headers = \GuzzleHttp\headers_from_lines($this->headers);
54
+ $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
55
+
56
+ if (!empty($this->options['decode_content'])
57
+ && isset($normalizedKeys['content-encoding'])
58
+ ) {
59
+ $headers['x-encoded-content-encoding']
60
+ = $headers[$normalizedKeys['content-encoding']];
61
+ unset($headers[$normalizedKeys['content-encoding']]);
62
+ if (isset($normalizedKeys['content-length'])) {
63
+ $headers['x-encoded-content-length']
64
+ = $headers[$normalizedKeys['content-length']];
65
+
66
+ $bodyLength = (int) $this->sink->getSize();
67
+ if ($bodyLength) {
68
+ $headers[$normalizedKeys['content-length']] = $bodyLength;
69
+ } else {
70
+ unset($headers[$normalizedKeys['content-length']]);
71
+ }
72
+ }
73
+ }
74
+
75
+ // Attach a response to the easy handle with the parsed headers.
76
+ $this->response = new Response(
77
+ $startLine[1],
78
+ $headers,
79
+ $this->sink,
80
+ substr($startLine[0], 5),
81
+ isset($startLine[2]) ? (string) $startLine[2] : null
82
+ );
83
+ }
84
+
85
+ public function __get($name)
86
+ {
87
+ $msg = $name === 'handle'
88
+ ? 'The EasyHandle has been released'
89
+ : 'Invalid property: ' . $name;
90
+ throw new \BadMethodCallException($msg);
91
+ }
92
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\HandlerStack;
5
+ use GuzzleHttp\Promise\PromiseInterface;
6
+ use GuzzleHttp\Promise\RejectedPromise;
7
+ use GuzzleHttp\TransferStats;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+
11
+ /**
12
+ * Handler that returns responses or throw exceptions from a queue.
13
+ */
14
+ class MockHandler implements \Countable
15
+ {
16
+ private $queue;
17
+ private $lastRequest;
18
+ private $lastOptions;
19
+ private $onFulfilled;
20
+ private $onRejected;
21
+
22
+ /**
23
+ * Creates a new MockHandler that uses the default handler stack list of
24
+ * middlewares.
25
+ *
26
+ * @param array $queue Array of responses, callables, or exceptions.
27
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
28
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
29
+ *
30
+ * @return MockHandler
31
+ */
32
+ public static function createWithMiddleware(
33
+ array $queue = null,
34
+ callable $onFulfilled = null,
35
+ callable $onRejected = null
36
+ ) {
37
+ return HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
38
+ }
39
+
40
+ /**
41
+ * The passed in value must be an array of
42
+ * {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions,
43
+ * callables, or Promises.
44
+ *
45
+ * @param array $queue
46
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
47
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
48
+ */
49
+ public function __construct(
50
+ array $queue = null,
51
+ callable $onFulfilled = null,
52
+ callable $onRejected = null
53
+ ) {
54
+ $this->onFulfilled = $onFulfilled;
55
+ $this->onRejected = $onRejected;
56
+
57
+ if ($queue) {
58
+ call_user_func_array([$this, 'append'], $queue);
59
+ }
60
+ }
61
+
62
+ public function __invoke(RequestInterface $request, array $options)
63
+ {
64
+ if (!$this->queue) {
65
+ throw new \OutOfBoundsException('Mock queue is empty');
66
+ }
67
+
68
+ if (isset($options['delay'])) {
69
+ usleep($options['delay'] * 1000);
70
+ }
71
+
72
+ $this->lastRequest = $request;
73
+ $this->lastOptions = $options;
74
+ $response = array_shift($this->queue);
75
+
76
+ if (is_callable($response)) {
77
+ $response = call_user_func($response, $request, $options);
78
+ }
79
+
80
+ $response = $response instanceof \Exception
81
+ ? new RejectedPromise($response)
82
+ : \GuzzleHttp\Promise\promise_for($response);
83
+
84
+ return $response->then(
85
+ function ($value) use ($request, $options) {
86
+ $this->invokeStats($request, $options, $value);
87
+ if ($this->onFulfilled) {
88
+ call_user_func($this->onFulfilled, $value);
89
+ }
90
+ if (isset($options['sink'])) {
91
+ $contents = (string) $value->getBody();
92
+ $sink = $options['sink'];
93
+
94
+ if (is_resource($sink)) {
95
+ fwrite($sink, $contents);
96
+ } elseif (is_string($sink)) {
97
+ file_put_contents($sink, $contents);
98
+ } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) {
99
+ $sink->write($contents);
100
+ }
101
+ }
102
+
103
+ return $value;
104
+ },
105
+ function ($reason) use ($request, $options) {
106
+ $this->invokeStats($request, $options, null, $reason);
107
+ if ($this->onRejected) {
108
+ call_user_func($this->onRejected, $reason);
109
+ }
110
+ return new RejectedPromise($reason);
111
+ }
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Adds one or more variadic requests, exceptions, callables, or promises
117
+ * to the queue.
118
+ */
119
+ public function append()
120
+ {
121
+ foreach (func_get_args() as $value) {
122
+ if ($value instanceof ResponseInterface
123
+ || $value instanceof \Exception
124
+ || $value instanceof PromiseInterface
125
+ || is_callable($value)
126
+ ) {
127
+ $this->queue[] = $value;
128
+ } else {
129
+ throw new \InvalidArgumentException('Expected a response or '
130
+ . 'exception. Found ' . \GuzzleHttp\describe_type($value));
131
+ }
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Get the last received request.
137
+ *
138
+ * @return RequestInterface
139
+ */
140
+ public function getLastRequest()
141
+ {
142
+ return $this->lastRequest;
143
+ }
144
+
145
+ /**
146
+ * Get the last received request options.
147
+ *
148
+ * @return RequestInterface
149
+ */
150
+ public function getLastOptions()
151
+ {
152
+ return $this->lastOptions;
153
+ }
154
+
155
+ /**
156
+ * Returns the number of remaining items in the queue.
157
+ *
158
+ * @return int
159
+ */
160
+ public function count()
161
+ {
162
+ return count($this->queue);
163
+ }
164
+
165
+ private function invokeStats(
166
+ RequestInterface $request,
167
+ array $options,
168
+ ResponseInterface $response = null,
169
+ $reason = null
170
+ ) {
171
+ if (isset($options['on_stats'])) {
172
+ $stats = new TransferStats($request, $response, 0, $reason);
173
+ call_user_func($options['on_stats'], $stats);
174
+ }
175
+ }
176
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\RequestOptions;
5
+ use Psr\Http\Message\RequestInterface;
6
+
7
+ /**
8
+ * Provides basic proxies for handlers.
9
+ */
10
+ class Proxy
11
+ {
12
+ /**
13
+ * Sends synchronous requests to a specific handler while sending all other
14
+ * requests to another handler.
15
+ *
16
+ * @param callable $default Handler used for normal responses
17
+ * @param callable $sync Handler used for synchronous responses.
18
+ *
19
+ * @return callable Returns the composed handler.
20
+ */
21
+ public static function wrapSync(
22
+ callable $default,
23
+ callable $sync
24
+ ) {
25
+ return function (RequestInterface $request, array $options) use ($default, $sync) {
26
+ return empty($options[RequestOptions::SYNCHRONOUS])
27
+ ? $default($request, $options)
28
+ : $sync($request, $options);
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Sends streaming requests to a streaming compatible handler while sending
34
+ * all other requests to a default handler.
35
+ *
36
+ * This, for example, could be useful for taking advantage of the
37
+ * performance benefits of curl while still supporting true streaming
38
+ * through the StreamHandler.
39
+ *
40
+ * @param callable $default Handler used for non-streaming responses
41
+ * @param callable $streaming Handler used for streaming responses
42
+ *
43
+ * @return callable Returns the composed handler.
44
+ */
45
+ public static function wrapStreaming(
46
+ callable $default,
47
+ callable $streaming
48
+ ) {
49
+ return function (RequestInterface $request, array $options) use ($default, $streaming) {
50
+ return empty($options['stream'])
51
+ ? $default($request, $options)
52
+ : $streaming($request, $options);
53
+ };
54
+ }
55
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use GuzzleHttp\Exception\RequestException;
5
+ use GuzzleHttp\Exception\ConnectException;
6
+ use GuzzleHttp\Promise\FulfilledPromise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Promise\PromiseInterface;
9
+ use GuzzleHttp\Psr7;
10
+ use GuzzleHttp\TransferStats;
11
+ use Psr\Http\Message\RequestInterface;
12
+ use Psr\Http\Message\ResponseInterface;
13
+ use Psr\Http\Message\StreamInterface;
14
+
15
+ /**
16
+ * HTTP handler that uses PHP's HTTP stream wrapper.
17
+ */
18
+ class StreamHandler
19
+ {
20
+ private $lastHeaders = [];
21
+
22
+ /**
23
+ * Sends an HTTP request.
24
+ *
25
+ * @param RequestInterface $request Request to send.
26
+ * @param array $options Request transfer options.
27
+ *
28
+ * @return PromiseInterface
29
+ */
30
+ public function __invoke(RequestInterface $request, array $options)
31
+ {
32
+ // Sleep if there is a delay specified.
33
+ if (isset($options['delay'])) {
34
+ usleep($options['delay'] * 1000);
35
+ }
36
+
37
+ $startTime = isset($options['on_stats']) ? microtime(true) : null;
38
+
39
+ try {
40
+ // Does not support the expect header.
41
+ $request = $request->withoutHeader('Expect');
42
+
43
+ // Append a content-length header if body size is zero to match
44
+ // cURL's behavior.
45
+ if (0 === $request->getBody()->getSize()) {
46
+ $request = $request->withHeader('Content-Length', 0);
47
+ }
48
+
49
+ return $this->createResponse(
50
+ $request,
51
+ $options,
52
+ $this->createStream($request, $options),
53
+ $startTime
54
+ );
55
+ } catch (\InvalidArgumentException $e) {
56
+ throw $e;
57
+ } catch (\Exception $e) {
58
+ // Determine if the error was a networking error.
59
+ $message = $e->getMessage();
60
+ // This list can probably get more comprehensive.
61
+ if (strpos($message, 'getaddrinfo') // DNS lookup failed
62
+ || strpos($message, 'Connection refused')
63
+ || strpos($message, "couldn't connect to host") // error on HHVM
64
+ ) {
65
+ $e = new ConnectException($e->getMessage(), $request, $e);
66
+ }
67
+ $e = RequestException::wrapException($request, $e);
68
+ $this->invokeStats($options, $request, $startTime, null, $e);
69
+
70
+ return new RejectedPromise($e);
71
+ }
72
+ }
73
+
74
+ private function invokeStats(
75
+ array $options,
76
+ RequestInterface $request,
77
+ $startTime,
78
+ ResponseInterface $response = null,
79
+ $error = null
80
+ ) {
81
+ if (isset($options['on_stats'])) {
82
+ $stats = new TransferStats(
83
+ $request,
84
+ $response,
85
+ microtime(true) - $startTime,
86
+ $error,
87
+ []
88
+ );
89
+ call_user_func($options['on_stats'], $stats);
90
+ }
91
+ }
92
+
93
+ private function createResponse(
94
+ RequestInterface $request,
95
+ array $options,
96
+ $stream,
97
+ $startTime
98
+ ) {
99
+ $hdrs = $this->lastHeaders;
100
+ $this->lastHeaders = [];
101
+ $parts = explode(' ', array_shift($hdrs), 3);
102
+ $ver = explode('/', $parts[0])[1];
103
+ $status = $parts[1];
104
+ $reason = isset($parts[2]) ? $parts[2] : null;
105
+ $headers = \GuzzleHttp\headers_from_lines($hdrs);
106
+ list ($stream, $headers) = $this->checkDecode($options, $headers, $stream);
107
+ $stream = Psr7\stream_for($stream);
108
+ $sink = $this->createSink($stream, $options);
109
+ $response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
110
+
111
+ if (isset($options['on_headers'])) {
112
+ try {
113
+ $options['on_headers']($response);
114
+ } catch (\Exception $e) {
115
+ $msg = 'An error was encountered during the on_headers event';
116
+ $ex = new RequestException($msg, $request, $response, $e);
117
+ return new RejectedPromise($ex);
118
+ }
119
+ }
120
+
121
+ if ($sink !== $stream) {
122
+ $this->drain($stream, $sink);
123
+ }
124
+
125
+ $this->invokeStats($options, $request, $startTime, $response, null);
126
+
127
+ return new FulfilledPromise($response);
128
+ }
129
+
130
+ private function createSink(StreamInterface $stream, array $options)
131
+ {
132
+ if (!empty($options['stream'])) {
133
+ return $stream;
134
+ }
135
+
136
+ $sink = isset($options['sink'])
137
+ ? $options['sink']
138
+ : fopen('php://temp', 'r+');
139
+
140
+ return is_string($sink)
141
+ ? new Psr7\LazyOpenStream($sink, 'w+')
142
+ : Psr7\stream_for($sink);
143
+ }
144
+
145
+ private function checkDecode(array $options, array $headers, $stream)
146
+ {
147
+ // Automatically decode responses when instructed.
148
+ if (!empty($options['decode_content'])) {
149
+ $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
150
+ if (isset($normalizedKeys['content-encoding'])) {
151
+ $encoding = $headers[$normalizedKeys['content-encoding']];
152
+ if ($encoding[0] == 'gzip' || $encoding[0] == 'deflate') {
153
+ $stream = new Psr7\InflateStream(
154
+ Psr7\stream_for($stream)
155
+ );
156
+ $headers['x-encoded-content-encoding']
157
+ = $headers[$normalizedKeys['content-encoding']];
158
+ // Remove content-encoding header
159
+ unset($headers[$normalizedKeys['content-encoding']]);
160
+ // Fix content-length header
161
+ if (isset($normalizedKeys['content-length'])) {
162
+ $headers['x-encoded-content-length']
163
+ = $headers[$normalizedKeys['content-length']];
164
+
165
+ $length = (int) $stream->getSize();
166
+ if ($length == 0) {
167
+ unset($headers[$normalizedKeys['content-length']]);
168
+ } else {
169
+ $headers[$normalizedKeys['content-length']] = [$length];
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+
176
+ return [$stream, $headers];
177
+ }
178
+
179
+ /**
180
+ * Drains the source stream into the "sink" client option.
181
+ *
182
+ * @param StreamInterface $source
183
+ * @param StreamInterface $sink
184
+ *
185
+ * @return StreamInterface
186
+ * @throws \RuntimeException when the sink option is invalid.
187
+ */
188
+ private function drain(StreamInterface $source, StreamInterface $sink)
189
+ {
190
+ Psr7\copy_to_stream($source, $sink);
191
+ $sink->seek(0);
192
+ $source->close();
193
+
194
+ return $sink;
195
+ }
196
+
197
+ /**
198
+ * Create a resource and check to ensure it was created successfully
199
+ *
200
+ * @param callable $callback Callable that returns stream resource
201
+ *
202
+ * @return resource
203
+ * @throws \RuntimeException on error
204
+ */
205
+ private function createResource(callable $callback)
206
+ {
207
+ $errors = null;
208
+ set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
209
+ $errors[] = [
210
+ 'message' => $msg,
211
+ 'file' => $file,
212
+ 'line' => $line
213
+ ];
214
+ return true;
215
+ });
216
+
217
+ $resource = $callback();
218
+ restore_error_handler();
219
+
220
+ if (!$resource) {
221
+ $message = 'Error creating resource: ';
222
+ foreach ($errors as $err) {
223
+ foreach ($err as $key => $value) {
224
+ $message .= "[$key] $value" . PHP_EOL;
225
+ }
226
+ }
227
+ throw new \RuntimeException(trim($message));
228
+ }
229
+
230
+ return $resource;
231
+ }
232
+
233
+ private function createStream(RequestInterface $request, array $options)
234
+ {
235
+ static $methods;
236
+ if (!$methods) {
237
+ $methods = array_flip(get_class_methods(__CLASS__));
238
+ }
239
+
240
+ // HTTP/1.1 streams using the PHP stream wrapper require a
241
+ // Connection: close header
242
+ if ($request->getProtocolVersion() == '1.1'
243
+ && !$request->hasHeader('Connection')
244
+ ) {
245
+ $request = $request->withHeader('Connection', 'close');
246
+ }
247
+
248
+ // Ensure SSL is verified by default
249
+ if (!isset($options['verify'])) {
250
+ $options['verify'] = true;
251
+ }
252
+
253
+ $params = [];
254
+ $context = $this->getDefaultContext($request, $options);
255
+
256
+ if (isset($options['on_headers']) && !is_callable($options['on_headers'])) {
257
+ throw new \InvalidArgumentException('on_headers must be callable');
258
+ }
259
+
260
+ if (!empty($options)) {
261
+ foreach ($options as $key => $value) {
262
+ $method = "add_{$key}";
263
+ if (isset($methods[$method])) {
264
+ $this->{$method}($request, $context, $value, $params);
265
+ }
266
+ }
267
+ }
268
+
269
+ if (isset($options['stream_context'])) {
270
+ if (!is_array($options['stream_context'])) {
271
+ throw new \InvalidArgumentException('stream_context must be an array');
272
+ }
273
+ $context = array_replace_recursive(
274
+ $context,
275
+ $options['stream_context']
276
+ );
277
+ }
278
+
279
+ $context = $this->createResource(
280
+ function () use ($context, $params) {
281
+ return stream_context_create($context, $params);
282
+ }
283
+ );
284
+
285
+ return $this->createResource(
286
+ function () use ($request, &$http_response_header, $context) {
287
+ $resource = fopen($request->getUri(), 'r', null, $context);
288
+ $this->lastHeaders = $http_response_header;
289
+ return $resource;
290
+ }
291
+ );
292
+ }
293
+
294
+ private function getDefaultContext(RequestInterface $request)
295
+ {
296
+ $headers = '';
297
+ foreach ($request->getHeaders() as $name => $value) {
298
+ foreach ($value as $val) {
299
+ $headers .= "$name: $val\r\n";
300
+ }
301
+ }
302
+
303
+ $context = [
304
+ 'http' => [
305
+ 'method' => $request->getMethod(),
306
+ 'header' => $headers,
307
+ 'protocol_version' => $request->getProtocolVersion(),
308
+ 'ignore_errors' => true,
309
+ 'follow_location' => 0,
310
+ ],
311
+ ];
312
+
313
+ $body = (string) $request->getBody();
314
+
315
+ if (!empty($body)) {
316
+ $context['http']['content'] = $body;
317
+ // Prevent the HTTP handler from adding a Content-Type header.
318
+ if (!$request->hasHeader('Content-Type')) {
319
+ $context['http']['header'] .= "Content-Type:\r\n";
320
+ }
321
+ }
322
+
323
+ $context['http']['header'] = rtrim($context['http']['header']);
324
+
325
+ return $context;
326
+ }
327
+
328
+ private function add_proxy(RequestInterface $request, &$options, $value, &$params)
329
+ {
330
+ if (!is_array($value)) {
331
+ $options['http']['proxy'] = $value;
332
+ } else {
333
+ $scheme = $request->getUri()->getScheme();
334
+ if (isset($value[$scheme])) {
335
+ if (!isset($value['no'])
336
+ || !\GuzzleHttp\is_host_in_noproxy(
337
+ $request->getUri()->getHost(),
338
+ $value['no']
339
+ )
340
+ ) {
341
+ $options['http']['proxy'] = $value[$scheme];
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ private function add_timeout(RequestInterface $request, &$options, $value, &$params)
348
+ {
349
+ $options['http']['timeout'] = $value;
350
+ }
351
+
352
+ private function add_verify(RequestInterface $request, &$options, $value, &$params)
353
+ {
354
+ if ($value === true) {
355
+ // PHP 5.6 or greater will find the system cert by default. When
356
+ // < 5.6, use the Guzzle bundled cacert.
357
+ if (PHP_VERSION_ID < 50600) {
358
+ $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle();
359
+ }
360
+ } elseif (is_string($value)) {
361
+ $options['ssl']['cafile'] = $value;
362
+ if (!file_exists($value)) {
363
+ throw new \RuntimeException("SSL CA bundle not found: $value");
364
+ }
365
+ } elseif ($value === false) {
366
+ $options['ssl']['verify_peer'] = false;
367
+ $options['ssl']['verify_peer_name'] = false;
368
+ return;
369
+ } else {
370
+ throw new \InvalidArgumentException('Invalid verify request option');
371
+ }
372
+
373
+ $options['ssl']['verify_peer'] = true;
374
+ $options['ssl']['verify_peer_name'] = true;
375
+ $options['ssl']['allow_self_signed'] = false;
376
+ }
377
+
378
+ private function add_cert(RequestInterface $request, &$options, $value, &$params)
379
+ {
380
+ if (is_array($value)) {
381
+ $options['ssl']['passphrase'] = $value[1];
382
+ $value = $value[0];
383
+ }
384
+
385
+ if (!file_exists($value)) {
386
+ throw new \RuntimeException("SSL certificate not found: {$value}");
387
+ }
388
+
389
+ $options['ssl']['local_cert'] = $value;
390
+ }
391
+
392
+ private function add_progress(RequestInterface $request, &$options, $value, &$params)
393
+ {
394
+ $this->addNotification(
395
+ $params,
396
+ function ($code, $a, $b, $c, $transferred, $total) use ($value) {
397
+ if ($code == STREAM_NOTIFY_PROGRESS) {
398
+ $value($total, $transferred, null, null);
399
+ }
400
+ }
401
+ );
402
+ }
403
+
404
+ private function add_debug(RequestInterface $request, &$options, $value, &$params)
405
+ {
406
+ if ($value === false) {
407
+ return;
408
+ }
409
+
410
+ static $map = [
411
+ STREAM_NOTIFY_CONNECT => 'CONNECT',
412
+ STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED',
413
+ STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT',
414
+ STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS',
415
+ STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS',
416
+ STREAM_NOTIFY_REDIRECTED => 'REDIRECTED',
417
+ STREAM_NOTIFY_PROGRESS => 'PROGRESS',
418
+ STREAM_NOTIFY_FAILURE => 'FAILURE',
419
+ STREAM_NOTIFY_COMPLETED => 'COMPLETED',
420
+ STREAM_NOTIFY_RESOLVE => 'RESOLVE',
421
+ ];
422
+ static $args = ['severity', 'message', 'message_code',
423
+ 'bytes_transferred', 'bytes_max'];
424
+
425
+ $value = \GuzzleHttp\debug_resource($value);
426
+ $ident = $request->getMethod() . ' ' . $request->getUri();
427
+ $this->addNotification(
428
+ $params,
429
+ function () use ($ident, $value, $map, $args) {
430
+ $passed = func_get_args();
431
+ $code = array_shift($passed);
432
+ fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
433
+ foreach (array_filter($passed) as $i => $v) {
434
+ fwrite($value, $args[$i] . ': "' . $v . '" ');
435
+ }
436
+ fwrite($value, "\n");
437
+ }
438
+ );
439
+ }
440
+
441
+ private function addNotification(array &$params, callable $notify)
442
+ {
443
+ // Wrap the existing function if needed.
444
+ if (!isset($params['notification'])) {
445
+ $params['notification'] = $notify;
446
+ } else {
447
+ $params['notification'] = $this->callArray([
448
+ $params['notification'],
449
+ $notify
450
+ ]);
451
+ }
452
+ }
453
+
454
+ private function callArray(array $functions)
455
+ {
456
+ return function () use ($functions) {
457
+ $args = func_get_args();
458
+ foreach ($functions as $fn) {
459
+ call_user_func_array($fn, $args);
460
+ }
461
+ };
462
+ }
463
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/HandlerStack.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ /**
7
+ * Creates a composed Guzzle handler function by stacking middlewares on top of
8
+ * an HTTP handler function.
9
+ */
10
+ class HandlerStack
11
+ {
12
+ /** @var callable */
13
+ private $handler;
14
+
15
+ /** @var array */
16
+ private $stack = [];
17
+
18
+ /** @var callable|null */
19
+ private $cached;
20
+
21
+ /**
22
+ * Creates a default handler stack that can be used by clients.
23
+ *
24
+ * The returned handler will wrap the provided handler or use the most
25
+ * appropriate default handler for you system. The returned HandlerStack has
26
+ * support for cookies, redirects, HTTP error exceptions, and preparing a body
27
+ * before sending.
28
+ *
29
+ * The returned handler stack can be passed to a client in the "handler"
30
+ * option.
31
+ *
32
+ * @param callable $handler HTTP handler function to use with the stack. If no
33
+ * handler is provided, the best handler for your
34
+ * system will be utilized.
35
+ *
36
+ * @return HandlerStack
37
+ */
38
+ public static function create(callable $handler = null)
39
+ {
40
+ $stack = new self($handler ?: choose_handler());
41
+ $stack->push(Middleware::httpErrors(), 'http_errors');
42
+ $stack->push(Middleware::redirect(), 'allow_redirects');
43
+ $stack->push(Middleware::cookies(), 'cookies');
44
+ $stack->push(Middleware::prepareBody(), 'prepare_body');
45
+
46
+ return $stack;
47
+ }
48
+
49
+ /**
50
+ * @param callable $handler Underlying HTTP handler.
51
+ */
52
+ public function __construct(callable $handler = null)
53
+ {
54
+ $this->handler = $handler;
55
+ }
56
+
57
+ /**
58
+ * Invokes the handler stack as a composed handler
59
+ *
60
+ * @param RequestInterface $request
61
+ * @param array $options
62
+ */
63
+ public function __invoke(RequestInterface $request, array $options)
64
+ {
65
+ $handler = $this->resolve();
66
+
67
+ return $handler($request, $options);
68
+ }
69
+
70
+ /**
71
+ * Dumps a string representation of the stack.
72
+ *
73
+ * @return string
74
+ */
75
+ public function __toString()
76
+ {
77
+ $depth = 0;
78
+ $stack = [];
79
+ if ($this->handler) {
80
+ $stack[] = "0) Handler: " . $this->debugCallable($this->handler);
81
+ }
82
+
83
+ $result = '';
84
+ foreach (array_reverse($this->stack) as $tuple) {
85
+ $depth++;
86
+ $str = "{$depth}) Name: '{$tuple[1]}', ";
87
+ $str .= "Function: " . $this->debugCallable($tuple[0]);
88
+ $result = "> {$str}\n{$result}";
89
+ $stack[] = $str;
90
+ }
91
+
92
+ foreach (array_keys($stack) as $k) {
93
+ $result .= "< {$stack[$k]}\n";
94
+ }
95
+
96
+ return $result;
97
+ }
98
+
99
+ /**
100
+ * Set the HTTP handler that actually returns a promise.
101
+ *
102
+ * @param callable $handler Accepts a request and array of options and
103
+ * returns a Promise.
104
+ */
105
+ public function setHandler(callable $handler)
106
+ {
107
+ $this->handler = $handler;
108
+ $this->cached = null;
109
+ }
110
+
111
+ /**
112
+ * Returns true if the builder has a handler.
113
+ *
114
+ * @return bool
115
+ */
116
+ public function hasHandler()
117
+ {
118
+ return (bool) $this->handler;
119
+ }
120
+
121
+ /**
122
+ * Unshift a middleware to the bottom of the stack.
123
+ *
124
+ * @param callable $middleware Middleware function
125
+ * @param string $name Name to register for this middleware.
126
+ */
127
+ public function unshift(callable $middleware, $name = null)
128
+ {
129
+ array_unshift($this->stack, [$middleware, $name]);
130
+ $this->cached = null;
131
+ }
132
+
133
+ /**
134
+ * Push a middleware to the top of the stack.
135
+ *
136
+ * @param callable $middleware Middleware function
137
+ * @param string $name Name to register for this middleware.
138
+ */
139
+ public function push(callable $middleware, $name = '')
140
+ {
141
+ $this->stack[] = [$middleware, $name];
142
+ $this->cached = null;
143
+ }
144
+
145
+ /**
146
+ * Add a middleware before another middleware by name.
147
+ *
148
+ * @param string $findName Middleware to find
149
+ * @param callable $middleware Middleware function
150
+ * @param string $withName Name to register for this middleware.
151
+ */
152
+ public function before($findName, callable $middleware, $withName = '')
153
+ {
154
+ $this->splice($findName, $withName, $middleware, true);
155
+ }
156
+
157
+ /**
158
+ * Add a middleware after another middleware by name.
159
+ *
160
+ * @param string $findName Middleware to find
161
+ * @param callable $middleware Middleware function
162
+ * @param string $withName Name to register for this middleware.
163
+ */
164
+ public function after($findName, callable $middleware, $withName = '')
165
+ {
166
+ $this->splice($findName, $withName, $middleware, false);
167
+ }
168
+
169
+ /**
170
+ * Remove a middleware by instance or name from the stack.
171
+ *
172
+ * @param callable|string $remove Middleware to remove by instance or name.
173
+ */
174
+ public function remove($remove)
175
+ {
176
+ $this->cached = null;
177
+ $idx = is_callable($remove) ? 0 : 1;
178
+ $this->stack = array_values(array_filter(
179
+ $this->stack,
180
+ function ($tuple) use ($idx, $remove) {
181
+ return $tuple[$idx] !== $remove;
182
+ }
183
+ ));
184
+ }
185
+
186
+ /**
187
+ * Compose the middleware and handler into a single callable function.
188
+ *
189
+ * @return callable
190
+ */
191
+ public function resolve()
192
+ {
193
+ if (!$this->cached) {
194
+ if (!($prev = $this->handler)) {
195
+ throw new \LogicException('No handler has been specified');
196
+ }
197
+
198
+ foreach (array_reverse($this->stack) as $fn) {
199
+ $prev = $fn[0]($prev);
200
+ }
201
+
202
+ $this->cached = $prev;
203
+ }
204
+
205
+ return $this->cached;
206
+ }
207
+
208
+ /**
209
+ * @param $name
210
+ * @return int
211
+ */
212
+ private function findByName($name)
213
+ {
214
+ foreach ($this->stack as $k => $v) {
215
+ if ($v[1] === $name) {
216
+ return $k;
217
+ }
218
+ }
219
+
220
+ throw new \InvalidArgumentException("Middleware not found: $name");
221
+ }
222
+
223
+ /**
224
+ * Splices a function into the middleware list at a specific position.
225
+ *
226
+ * @param $findName
227
+ * @param $withName
228
+ * @param callable $middleware
229
+ * @param $before
230
+ */
231
+ private function splice($findName, $withName, callable $middleware, $before)
232
+ {
233
+ $this->cached = null;
234
+ $idx = $this->findByName($findName);
235
+ $tuple = [$middleware, $withName];
236
+
237
+ if ($before) {
238
+ if ($idx === 0) {
239
+ array_unshift($this->stack, $tuple);
240
+ } else {
241
+ $replacement = [$tuple, $this->stack[$idx]];
242
+ array_splice($this->stack, $idx, 1, $replacement);
243
+ }
244
+ } elseif ($idx === count($this->stack) - 1) {
245
+ $this->stack[] = $tuple;
246
+ } else {
247
+ $replacement = [$this->stack[$idx], $tuple];
248
+ array_splice($this->stack, $idx, 1, $replacement);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Provides a debug string for a given callable.
254
+ *
255
+ * @param array|callable $fn Function to write as a string.
256
+ *
257
+ * @return string
258
+ */
259
+ private function debugCallable($fn)
260
+ {
261
+ if (is_string($fn)) {
262
+ return "callable({$fn})";
263
+ }
264
+
265
+ if (is_array($fn)) {
266
+ return is_string($fn[0])
267
+ ? "callable({$fn[0]}::{$fn[1]})"
268
+ : "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])";
269
+ }
270
+
271
+ return 'callable(' . spl_object_hash($fn) . ')';
272
+ }
273
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/MessageFormatter.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\MessageInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+
8
+ /**
9
+ * Formats log messages using variable substitutions for requests, responses,
10
+ * and other transactional data.
11
+ *
12
+ * The following variable substitutions are supported:
13
+ *
14
+ * - {request}: Full HTTP request message
15
+ * - {response}: Full HTTP response message
16
+ * - {ts}: ISO 8601 date in GMT
17
+ * - {date_iso_8601} ISO 8601 date in GMT
18
+ * - {date_common_log} Apache common log date using the configured timezone.
19
+ * - {host}: Host of the request
20
+ * - {method}: Method of the request
21
+ * - {uri}: URI of the request
22
+ * - {host}: Host of the request
23
+ * - {version}: Protocol version
24
+ * - {target}: Request target of the request (path + query + fragment)
25
+ * - {hostname}: Hostname of the machine that sent the request
26
+ * - {code}: Status code of the response (if available)
27
+ * - {phrase}: Reason phrase of the response (if available)
28
+ * - {error}: Any error messages (if available)
29
+ * - {req_header_*}: Replace `*` with the lowercased name of a request header to add to the message
30
+ * - {res_header_*}: Replace `*` with the lowercased name of a response header to add to the message
31
+ * - {req_headers}: Request headers
32
+ * - {res_headers}: Response headers
33
+ * - {req_body}: Request body
34
+ * - {res_body}: Response body
35
+ */
36
+ class MessageFormatter
37
+ {
38
+ /**
39
+ * Apache Common Log Format.
40
+ * @link http://httpd.apache.org/docs/2.4/logs.html#common
41
+ * @var string
42
+ */
43
+ const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
44
+ const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
45
+ const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
46
+
47
+ /** @var string Template used to format log messages */
48
+ private $template;
49
+
50
+ /**
51
+ * @param string $template Log message template
52
+ */
53
+ public function __construct($template = self::CLF)
54
+ {
55
+ $this->template = $template ?: self::CLF;
56
+ }
57
+
58
+ /**
59
+ * Returns a formatted message string.
60
+ *
61
+ * @param RequestInterface $request Request that was sent
62
+ * @param ResponseInterface $response Response that was received
63
+ * @param \Exception $error Exception that was received
64
+ *
65
+ * @return string
66
+ */
67
+ public function format(
68
+ RequestInterface $request,
69
+ ResponseInterface $response = null,
70
+ \Exception $error = null
71
+ ) {
72
+ $cache = [];
73
+
74
+ return preg_replace_callback(
75
+ '/{\s*([A-Za-z_\-\.0-9]+)\s*}/',
76
+ function (array $matches) use ($request, $response, $error, &$cache) {
77
+
78
+ if (isset($cache[$matches[1]])) {
79
+ return $cache[$matches[1]];
80
+ }
81
+
82
+ $result = '';
83
+ switch ($matches[1]) {
84
+ case 'request':
85
+ $result = Psr7\str($request);
86
+ break;
87
+ case 'response':
88
+ $result = $response ? Psr7\str($response) : '';
89
+ break;
90
+ case 'req_headers':
91
+ $result = trim($request->getMethod()
92
+ . ' ' . $request->getRequestTarget())
93
+ . ' HTTP/' . $request->getProtocolVersion() . "\r\n"
94
+ . $this->headers($request);
95
+ break;
96
+ case 'res_headers':
97
+ $result = $response ?
98
+ sprintf(
99
+ 'HTTP/%s %d %s',
100
+ $response->getProtocolVersion(),
101
+ $response->getStatusCode(),
102
+ $response->getReasonPhrase()
103
+ ) . "\r\n" . $this->headers($response)
104
+ : 'NULL';
105
+ break;
106
+ case 'req_body':
107
+ $result = $request->getBody();
108
+ break;
109
+ case 'res_body':
110
+ $result = $response ? $response->getBody() : 'NULL';
111
+ break;
112
+ case 'ts':
113
+ case 'date_iso_8601':
114
+ $result = gmdate('c');
115
+ break;
116
+ case 'date_common_log':
117
+ $result = date('d/M/Y:H:i:s O');
118
+ break;
119
+ case 'method':
120
+ $result = $request->getMethod();
121
+ break;
122
+ case 'version':
123
+ $result = $request->getProtocolVersion();
124
+ break;
125
+ case 'uri':
126
+ case 'url':
127
+ $result = $request->getUri();
128
+ break;
129
+ case 'target':
130
+ $result = $request->getRequestTarget();
131
+ break;
132
+ case 'req_version':
133
+ $result = $request->getProtocolVersion();
134
+ break;
135
+ case 'res_version':
136
+ $result = $response
137
+ ? $response->getProtocolVersion()
138
+ : 'NULL';
139
+ break;
140
+ case 'host':
141
+ $result = $request->getHeaderLine('Host');
142
+ break;
143
+ case 'hostname':
144
+ $result = gethostname();
145
+ break;
146
+ case 'code':
147
+ $result = $response ? $response->getStatusCode() : 'NULL';
148
+ break;
149
+ case 'phrase':
150
+ $result = $response ? $response->getReasonPhrase() : 'NULL';
151
+ break;
152
+ case 'error':
153
+ $result = $error ? $error->getMessage() : 'NULL';
154
+ break;
155
+ default:
156
+ // handle prefixed dynamic headers
157
+ if (strpos($matches[1], 'req_header_') === 0) {
158
+ $result = $request->getHeaderLine(substr($matches[1], 11));
159
+ } elseif (strpos($matches[1], 'res_header_') === 0) {
160
+ $result = $response
161
+ ? $response->getHeaderLine(substr($matches[1], 11))
162
+ : 'NULL';
163
+ }
164
+ }
165
+
166
+ $cache[$matches[1]] = $result;
167
+ return $result;
168
+ },
169
+ $this->template
170
+ );
171
+ }
172
+
173
+ private function headers(MessageInterface $message)
174
+ {
175
+ $result = '';
176
+ foreach ($message->getHeaders() as $name => $values) {
177
+ $result .= $name . ': ' . implode(', ', $values) . "\r\n";
178
+ }
179
+
180
+ return trim($result);
181
+ }
182
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Middleware.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Cookie\CookieJarInterface;
5
+ use GuzzleHttp\Exception\RequestException;
6
+ use GuzzleHttp\Promise\RejectedPromise;
7
+ use GuzzleHttp\Psr7;
8
+ use Psr\Http\Message\ResponseInterface;
9
+ use Psr\Log\LoggerInterface;
10
+ use Psr\Log\LogLevel;
11
+
12
+ /**
13
+ * Functions used to create and wrap handlers with handler middleware.
14
+ */
15
+ final class Middleware
16
+ {
17
+ /**
18
+ * Middleware that adds cookies to requests.
19
+ *
20
+ * The options array must be set to a CookieJarInterface in order to use
21
+ * cookies. This is typically handled for you by a client.
22
+ *
23
+ * @return callable Returns a function that accepts the next handler.
24
+ */
25
+ public static function cookies()
26
+ {
27
+ return function (callable $handler) {
28
+ return function ($request, array $options) use ($handler) {
29
+ if (empty($options['cookies'])) {
30
+ return $handler($request, $options);
31
+ } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
32
+ throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
33
+ }
34
+ $cookieJar = $options['cookies'];
35
+ $request = $cookieJar->withCookieHeader($request);
36
+ return $handler($request, $options)
37
+ ->then(function ($response) use ($cookieJar, $request) {
38
+ $cookieJar->extractCookies($request, $response);
39
+ return $response;
40
+ }
41
+ );
42
+ };
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Middleware that throws exceptions for 4xx or 5xx responses when the
48
+ * "http_error" request option is set to true.
49
+ *
50
+ * @return callable Returns a function that accepts the next handler.
51
+ */
52
+ public static function httpErrors()
53
+ {
54
+ return function (callable $handler) {
55
+ return function ($request, array $options) use ($handler) {
56
+ if (empty($options['http_errors'])) {
57
+ return $handler($request, $options);
58
+ }
59
+ return $handler($request, $options)->then(
60
+ function (ResponseInterface $response) use ($request, $handler) {
61
+ $code = $response->getStatusCode();
62
+ if ($code < 400) {
63
+ return $response;
64
+ }
65
+ throw RequestException::create($request, $response);
66
+ }
67
+ );
68
+ };
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Middleware that pushes history data to an ArrayAccess container.
74
+ *
75
+ * @param array $container Container to hold the history (by reference).
76
+ *
77
+ * @return callable Returns a function that accepts the next handler.
78
+ * @throws \InvalidArgumentException if container is not an array or ArrayAccess.
79
+ */
80
+ public static function history(&$container)
81
+ {
82
+ if (!is_array($container) && !$container instanceof \ArrayAccess) {
83
+ throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
84
+ }
85
+
86
+ return function (callable $handler) use (&$container) {
87
+ return function ($request, array $options) use ($handler, &$container) {
88
+ return $handler($request, $options)->then(
89
+ function ($value) use ($request, &$container, $options) {
90
+ $container[] = [
91
+ 'request' => $request,
92
+ 'response' => $value,
93
+ 'error' => null,
94
+ 'options' => $options
95
+ ];
96
+ return $value;
97
+ },
98
+ function ($reason) use ($request, &$container, $options) {
99
+ $container[] = [
100
+ 'request' => $request,
101
+ 'response' => null,
102
+ 'error' => $reason,
103
+ 'options' => $options
104
+ ];
105
+ return new RejectedPromise($reason);
106
+ }
107
+ );
108
+ };
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Middleware that invokes a callback before and after sending a request.
114
+ *
115
+ * The provided listener cannot modify or alter the response. It simply
116
+ * "taps" into the chain to be notified before returning the promise. The
117
+ * before listener accepts a request and options array, and the after
118
+ * listener accepts a request, options array, and response promise.
119
+ *
120
+ * @param callable $before Function to invoke before forwarding the request.
121
+ * @param callable $after Function invoked after forwarding.
122
+ *
123
+ * @return callable Returns a function that accepts the next handler.
124
+ */
125
+ public static function tap(callable $before = null, callable $after = null)
126
+ {
127
+ return function (callable $handler) use ($before, $after) {
128
+ return function ($request, array $options) use ($handler, $before, $after) {
129
+ if ($before) {
130
+ $before($request, $options);
131
+ }
132
+ $response = $handler($request, $options);
133
+ if ($after) {
134
+ $after($request, $options, $response);
135
+ }
136
+ return $response;
137
+ };
138
+ };
139
+ }
140
+
141
+ /**
142
+ * Middleware that handles request redirects.
143
+ *
144
+ * @return callable Returns a function that accepts the next handler.
145
+ */
146
+ public static function redirect()
147
+ {
148
+ return function (callable $handler) {
149
+ return new RedirectMiddleware($handler);
150
+ };
151
+ }
152
+
153
+ /**
154
+ * Middleware that retries requests based on the boolean result of
155
+ * invoking the provided "decider" function.
156
+ *
157
+ * If no delay function is provided, a simple implementation of exponential
158
+ * backoff will be utilized.
159
+ *
160
+ * @param callable $decider Function that accepts the number of retries,
161
+ * a request, [response], and [exception] and
162
+ * returns true if the request is to be retried.
163
+ * @param callable $delay Function that accepts the number of retries and
164
+ * returns the number of milliseconds to delay.
165
+ *
166
+ * @return callable Returns a function that accepts the next handler.
167
+ */
168
+ public static function retry(callable $decider, callable $delay = null)
169
+ {
170
+ return function (callable $handler) use ($decider, $delay) {
171
+ return new RetryMiddleware($decider, $handler, $delay);
172
+ };
173
+ }
174
+
175
+ /**
176
+ * Middleware that logs requests, responses, and errors using a message
177
+ * formatter.
178
+ *
179
+ * @param LoggerInterface $logger Logs messages.
180
+ * @param MessageFormatter $formatter Formatter used to create message strings.
181
+ * @param string $logLevel Level at which to log requests.
182
+ *
183
+ * @return callable Returns a function that accepts the next handler.
184
+ */
185
+ public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO)
186
+ {
187
+ return function (callable $handler) use ($logger, $formatter, $logLevel) {
188
+ return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
189
+ return $handler($request, $options)->then(
190
+ function ($response) use ($logger, $request, $formatter, $logLevel) {
191
+ $message = $formatter->format($request, $response);
192
+ $logger->log($logLevel, $message);
193
+ return $response;
194
+ },
195
+ function ($reason) use ($logger, $request, $formatter) {
196
+ $response = $reason instanceof RequestException
197
+ ? $reason->getResponse()
198
+ : null;
199
+ $message = $formatter->format($request, $response, $reason);
200
+ $logger->notice($message);
201
+ return \GuzzleHttp\Promise\rejection_for($reason);
202
+ }
203
+ );
204
+ };
205
+ };
206
+ }
207
+
208
+ /**
209
+ * This middleware adds a default content-type if possible, a default
210
+ * content-length or transfer-encoding header, and the expect header.
211
+ *
212
+ * @return callable
213
+ */
214
+ public static function prepareBody()
215
+ {
216
+ return function (callable $handler) {
217
+ return new PrepareBodyMiddleware($handler);
218
+ };
219
+ }
220
+
221
+ /**
222
+ * Middleware that applies a map function to the request before passing to
223
+ * the next handler.
224
+ *
225
+ * @param callable $fn Function that accepts a RequestInterface and returns
226
+ * a RequestInterface.
227
+ * @return callable
228
+ */
229
+ public static function mapRequest(callable $fn)
230
+ {
231
+ return function (callable $handler) use ($fn) {
232
+ return function ($request, array $options) use ($handler, $fn) {
233
+ return $handler($fn($request), $options);
234
+ };
235
+ };
236
+ }
237
+
238
+ /**
239
+ * Middleware that applies a map function to the resolved promise's
240
+ * response.
241
+ *
242
+ * @param callable $fn Function that accepts a ResponseInterface and
243
+ * returns a ResponseInterface.
244
+ * @return callable
245
+ */
246
+ public static function mapResponse(callable $fn)
247
+ {
248
+ return function (callable $handler) use ($fn) {
249
+ return function ($request, array $options) use ($handler, $fn) {
250
+ return $handler($request, $options)->then($fn);
251
+ };
252
+ };
253
+ }
254
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/Pool.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromisorInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use GuzzleHttp\Promise\EachPromise;
7
+
8
+ /**
9
+ * Sends and iterator of requests concurrently using a capped pool size.
10
+ *
11
+ * The pool will read from an iterator until it is cancelled or until the
12
+ * iterator is consumed. When a request is yielded, the request is sent after
13
+ * applying the "request_options" request options (if provided in the ctor).
14
+ *
15
+ * When a function is yielded by the iterator, the function is provided the
16
+ * "request_options" array that should be merged on top of any existing
17
+ * options, and the function MUST then return a wait-able promise.
18
+ */
19
+ class Pool implements PromisorInterface
20
+ {
21
+ /** @var EachPromise */
22
+ private $each;
23
+
24
+ /**
25
+ * @param ClientInterface $client Client used to send the requests.
26
+ * @param array|\Iterator $requests Requests or functions that return
27
+ * requests to send concurrently.
28
+ * @param array $config Associative array of options
29
+ * - concurrency: (int) Maximum number of requests to send concurrently
30
+ * - options: Array of request options to apply to each request.
31
+ * - fulfilled: (callable) Function to invoke when a request completes.
32
+ * - rejected: (callable) Function to invoke when a request is rejected.
33
+ */
34
+ public function __construct(
35
+ ClientInterface $client,
36
+ $requests,
37
+ array $config = []
38
+ ) {
39
+ // Backwards compatibility.
40
+ if (isset($config['pool_size'])) {
41
+ $config['concurrency'] = $config['pool_size'];
42
+ } elseif (!isset($config['concurrency'])) {
43
+ $config['concurrency'] = 25;
44
+ }
45
+
46
+ if (isset($config['options'])) {
47
+ $opts = $config['options'];
48
+ unset($config['options']);
49
+ } else {
50
+ $opts = [];
51
+ }
52
+
53
+ $iterable = \GuzzleHttp\Promise\iter_for($requests);
54
+ $requests = function () use ($iterable, $client, $opts) {
55
+ foreach ($iterable as $key => $rfn) {
56
+ if ($rfn instanceof RequestInterface) {
57
+ yield $key => $client->sendAsync($rfn, $opts);
58
+ } elseif (is_callable($rfn)) {
59
+ yield $key => $rfn($opts);
60
+ } else {
61
+ throw new \InvalidArgumentException('Each value yielded by '
62
+ . 'the iterator must be a Psr7\Http\Message\RequestInterface '
63
+ . 'or a callable that returns a promise that fulfills '
64
+ . 'with a Psr7\Message\Http\ResponseInterface object.');
65
+ }
66
+ }
67
+ };
68
+
69
+ $this->each = new EachPromise($requests(), $config);
70
+ }
71
+
72
+ public function promise()
73
+ {
74
+ return $this->each->promise();
75
+ }
76
+
77
+ /**
78
+ * Sends multiple requests concurrently and returns an array of responses
79
+ * and exceptions that uses the same ordering as the provided requests.
80
+ *
81
+ * IMPORTANT: This method keeps every request and response in memory, and
82
+ * as such, is NOT recommended when sending a large number or an
83
+ * indeterminate number of requests concurrently.
84
+ *
85
+ * @param ClientInterface $client Client used to send the requests
86
+ * @param array|\Iterator $requests Requests to send concurrently.
87
+ * @param array $options Passes through the options available in
88
+ * {@see GuzzleHttp\Pool::__construct}
89
+ *
90
+ * @return array Returns an array containing the response or an exception
91
+ * in the same order that the requests were sent.
92
+ * @throws \InvalidArgumentException if the event format is incorrect.
93
+ */
94
+ public static function batch(
95
+ ClientInterface $client,
96
+ $requests,
97
+ array $options = []
98
+ ) {
99
+ $res = [];
100
+ self::cmpCallback($options, 'fulfilled', $res);
101
+ self::cmpCallback($options, 'rejected', $res);
102
+ $pool = new static($client, $requests, $options);
103
+ $pool->promise()->wait();
104
+ ksort($res);
105
+
106
+ return $res;
107
+ }
108
+
109
+ private static function cmpCallback(array &$options, $name, array &$results)
110
+ {
111
+ if (!isset($options[$name])) {
112
+ $options[$name] = function ($v, $k) use (&$results) {
113
+ $results[$k] = $v;
114
+ };
115
+ } else {
116
+ $currentFn = $options[$name];
117
+ $options[$name] = function ($v, $k) use (&$results, $currentFn) {
118
+ $currentFn($v, $k);
119
+ $results[$k] = $v;
120
+ };
121
+ }
122
+ }
123
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Psr7;
6
+ use Psr\Http\Message\RequestInterface;
7
+
8
+ /**
9
+ * Prepares requests that contain a body, adding the Content-Length,
10
+ * Content-Type, and Expect headers.
11
+ */
12
+ class PrepareBodyMiddleware
13
+ {
14
+ /** @var callable */
15
+ private $nextHandler;
16
+
17
+ /** @var array */
18
+ private static $skipMethods = ['GET' => true, 'HEAD' => true];
19
+
20
+ /**
21
+ * @param callable $nextHandler Next handler to invoke.
22
+ */
23
+ public function __construct(callable $nextHandler)
24
+ {
25
+ $this->nextHandler = $nextHandler;
26
+ }
27
+
28
+ /**
29
+ * @param RequestInterface $request
30
+ * @param array $options
31
+ *
32
+ * @return PromiseInterface
33
+ */
34
+ public function __invoke(RequestInterface $request, array $options)
35
+ {
36
+ $fn = $this->nextHandler;
37
+
38
+ // Don't do anything if the request has no body.
39
+ if (isset(self::$skipMethods[$request->getMethod()])
40
+ || $request->getBody()->getSize() === 0
41
+ ) {
42
+ return $fn($request, $options);
43
+ }
44
+
45
+ $modify = [];
46
+
47
+ // Add a default content-type if possible.
48
+ if (!$request->hasHeader('Content-Type')) {
49
+ if ($uri = $request->getBody()->getMetadata('uri')) {
50
+ if ($type = Psr7\mimetype_from_filename($uri)) {
51
+ $modify['set_headers']['Content-Type'] = $type;
52
+ }
53
+ }
54
+ }
55
+
56
+ // Add a default content-length or transfer-encoding header.
57
+ if (!isset(self::$skipMethods[$request->getMethod()])
58
+ && !$request->hasHeader('Content-Length')
59
+ && !$request->hasHeader('Transfer-Encoding')
60
+ ) {
61
+ $size = $request->getBody()->getSize();
62
+ if ($size !== null) {
63
+ $modify['set_headers']['Content-Length'] = $size;
64
+ } else {
65
+ $modify['set_headers']['Transfer-Encoding'] = 'chunked';
66
+ }
67
+ }
68
+
69
+ // Add the expect header if needed.
70
+ $this->addExpectHeader($request, $options, $modify);
71
+
72
+ return $fn(Psr7\modify_request($request, $modify), $options);
73
+ }
74
+
75
+ private function addExpectHeader(
76
+ RequestInterface $request,
77
+ array $options,
78
+ array &$modify
79
+ ) {
80
+ // Determine if the Expect header should be used
81
+ if ($request->hasHeader('Expect')) {
82
+ return;
83
+ }
84
+
85
+ $expect = isset($options['expect']) ? $options['expect'] : null;
86
+
87
+ // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
88
+ if ($expect === false || $request->getProtocolVersion() < 1.1) {
89
+ return;
90
+ }
91
+
92
+ // The expect header is unconditionally enabled
93
+ if ($expect === true) {
94
+ $modify['set_headers']['Expect'] = '100-Continue';
95
+ return;
96
+ }
97
+
98
+ // By default, send the expect header when the payload is > 1mb
99
+ if ($expect === null) {
100
+ $expect = 1048576;
101
+ }
102
+
103
+ // Always add if the body cannot be rewound, the size cannot be
104
+ // determined, or the size is greater than the cutoff threshold
105
+ $body = $request->getBody();
106
+ $size = $body->getSize();
107
+
108
+ if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
109
+ $modify['set_headers']['Expect'] = '100-Continue';
110
+ }
111
+ }
112
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Exception\BadResponseException;
5
+ use GuzzleHttp\Exception\TooManyRedirectsException;
6
+ use GuzzleHttp\Promise\PromiseInterface;
7
+ use GuzzleHttp\Psr7;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+ use Psr\Http\Message\UriInterface;
11
+
12
+ /**
13
+ * Request redirect middleware.
14
+ *
15
+ * Apply this middleware like other middleware using
16
+ * {@see GuzzleHttp\Middleware::redirect()}.
17
+ */
18
+ class RedirectMiddleware
19
+ {
20
+ const HISTORY_HEADER = 'X-Guzzle-Redirect-History';
21
+
22
+ public static $defaultSettings = [
23
+ 'max' => 5,
24
+ 'protocols' => ['http', 'https'],
25
+ 'strict' => false,
26
+ 'referer' => false,
27
+ 'track_redirects' => false,
28
+ ];
29
+
30
+ /** @var callable */
31
+ private $nextHandler;
32
+
33
+ /**
34
+ * @param callable $nextHandler Next handler to invoke.
35
+ */
36
+ public function __construct(callable $nextHandler)
37
+ {
38
+ $this->nextHandler = $nextHandler;
39
+ }
40
+
41
+ /**
42
+ * @param RequestInterface $request
43
+ * @param array $options
44
+ *
45
+ * @return PromiseInterface
46
+ */
47
+ public function __invoke(RequestInterface $request, array $options)
48
+ {
49
+ $fn = $this->nextHandler;
50
+
51
+ if (empty($options['allow_redirects'])) {
52
+ return $fn($request, $options);
53
+ }
54
+
55
+ if ($options['allow_redirects'] === true) {
56
+ $options['allow_redirects'] = self::$defaultSettings;
57
+ } elseif (!is_array($options['allow_redirects'])) {
58
+ throw new \InvalidArgumentException('allow_redirects must be true, false, or array');
59
+ } else {
60
+ // Merge the default settings with the provided settings
61
+ $options['allow_redirects'] += self::$defaultSettings;
62
+ }
63
+
64
+ if (empty($options['allow_redirects']['max'])) {
65
+ return $fn($request, $options);
66
+ }
67
+
68
+ return $fn($request, $options)
69
+ ->then(function (ResponseInterface $response) use ($request, $options) {
70
+ return $this->checkRedirect($request, $options, $response);
71
+ });
72
+ }
73
+
74
+ /**
75
+ * @param RequestInterface $request
76
+ * @param array $options
77
+ * @param ResponseInterface|PromiseInterface $response
78
+ *
79
+ * @return ResponseInterface|PromiseInterface
80
+ */
81
+ public function checkRedirect(
82
+ RequestInterface $request,
83
+ array $options,
84
+ ResponseInterface $response
85
+ ) {
86
+ if (substr($response->getStatusCode(), 0, 1) != '3'
87
+ || !$response->hasHeader('Location')
88
+ ) {
89
+ return $response;
90
+ }
91
+
92
+ $this->guardMax($request, $options);
93
+ $nextRequest = $this->modifyRequest($request, $options, $response);
94
+
95
+ if (isset($options['allow_redirects']['on_redirect'])) {
96
+ call_user_func(
97
+ $options['allow_redirects']['on_redirect'],
98
+ $request,
99
+ $response,
100
+ $nextRequest->getUri()
101
+ );
102
+ }
103
+
104
+ /** @var PromiseInterface|ResponseInterface $promise */
105
+ $promise = $this($nextRequest, $options);
106
+
107
+ // Add headers to be able to track history of redirects.
108
+ if (!empty($options['allow_redirects']['track_redirects'])) {
109
+ return $this->withTracking(
110
+ $promise,
111
+ (string) $nextRequest->getUri()
112
+ );
113
+ }
114
+
115
+ return $promise;
116
+ }
117
+
118
+ private function withTracking(PromiseInterface $promise, $uri)
119
+ {
120
+ return $promise->then(
121
+ function (ResponseInterface $response) use ($uri) {
122
+ // Note that we are pushing to the front of the list as this
123
+ // would be an earlier response than what is currently present
124
+ // in the history header.
125
+ $header = $response->getHeader(self::HISTORY_HEADER);
126
+ array_unshift($header, $uri);
127
+ return $response->withHeader(self::HISTORY_HEADER, $header);
128
+ }
129
+ );
130
+ }
131
+
132
+ private function guardMax(RequestInterface $request, array &$options)
133
+ {
134
+ $current = isset($options['__redirect_count'])
135
+ ? $options['__redirect_count']
136
+ : 0;
137
+ $options['__redirect_count'] = $current + 1;
138
+ $max = $options['allow_redirects']['max'];
139
+
140
+ if ($options['__redirect_count'] > $max) {
141
+ throw new TooManyRedirectsException(
142
+ "Will not follow more than {$max} redirects",
143
+ $request
144
+ );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * @param RequestInterface $request
150
+ * @param array $options
151
+ * @param ResponseInterface $response
152
+ *
153
+ * @return RequestInterface
154
+ */
155
+ public function modifyRequest(
156
+ RequestInterface $request,
157
+ array $options,
158
+ ResponseInterface $response
159
+ ) {
160
+ // Request modifications to apply.
161
+ $modify = [];
162
+ $protocols = $options['allow_redirects']['protocols'];
163
+
164
+ // Use a GET request if this is an entity enclosing request and we are
165
+ // not forcing RFC compliance, but rather emulating what all browsers
166
+ // would do.
167
+ $statusCode = $response->getStatusCode();
168
+ if ($statusCode == 303 ||
169
+ ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict'])
170
+ ) {
171
+ $modify['method'] = 'GET';
172
+ $modify['body'] = '';
173
+ }
174
+
175
+ $modify['uri'] = $this->redirectUri($request, $response, $protocols);
176
+ Psr7\rewind_body($request);
177
+
178
+ // Add the Referer header if it is told to do so and only
179
+ // add the header if we are not redirecting from https to http.
180
+ if ($options['allow_redirects']['referer']
181
+ && $modify['uri']->getScheme() === $request->getUri()->getScheme()
182
+ ) {
183
+ $uri = $request->getUri()->withUserInfo('', '');
184
+ $modify['set_headers']['Referer'] = (string) $uri;
185
+ } else {
186
+ $modify['remove_headers'][] = 'Referer';
187
+ }
188
+
189
+ // Remove Authorization header if host is different.
190
+ if ($request->getUri()->getHost() !== $modify['uri']->getHost()) {
191
+ $modify['remove_headers'][] = 'Authorization';
192
+ }
193
+
194
+ return Psr7\modify_request($request, $modify);
195
+ }
196
+
197
+ /**
198
+ * Set the appropriate URL on the request based on the location header
199
+ *
200
+ * @param RequestInterface $request
201
+ * @param ResponseInterface $response
202
+ * @param array $protocols
203
+ *
204
+ * @return UriInterface
205
+ */
206
+ private function redirectUri(
207
+ RequestInterface $request,
208
+ ResponseInterface $response,
209
+ array $protocols
210
+ ) {
211
+ $location = Psr7\Uri::resolve(
212
+ $request->getUri(),
213
+ $response->getHeaderLine('Location')
214
+ );
215
+
216
+ // Ensure that the redirect URI is allowed based on the protocols.
217
+ if (!in_array($location->getScheme(), $protocols)) {
218
+ throw new BadResponseException(
219
+ sprintf(
220
+ 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
221
+ $location,
222
+ implode(', ', $protocols)
223
+ ),
224
+ $request,
225
+ $response
226
+ );
227
+ }
228
+
229
+ return $location;
230
+ }
231
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RequestOptions.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * This class contains a list of built-in Guzzle request options.
6
+ *
7
+ * More documentation for each option can be found at http://guzzlephp.org/.
8
+ *
9
+ * @link http://docs.guzzlephp.org/en/v6/request-options.html
10
+ */
11
+ final class RequestOptions
12
+ {
13
+ /**
14
+ * allow_redirects: (bool|array) Controls redirect behavior. Pass false
15
+ * to disable redirects, pass true to enable redirects, pass an
16
+ * associative to provide custom redirect settings. Defaults to "false".
17
+ * This option only works if your handler has the RedirectMiddleware. When
18
+ * passing an associative array, you can provide the following key value
19
+ * pairs:
20
+ *
21
+ * - max: (int, default=5) maximum number of allowed redirects.
22
+ * - strict: (bool, default=false) Set to true to use strict redirects
23
+ * meaning redirect POST requests with POST requests vs. doing what most
24
+ * browsers do which is redirect POST requests with GET requests
25
+ * - referer: (bool, default=true) Set to false to disable the Referer
26
+ * header.
27
+ * - protocols: (array, default=['http', 'https']) Allowed redirect
28
+ * protocols.
29
+ * - on_redirect: (callable) PHP callable that is invoked when a redirect
30
+ * is encountered. The callable is invoked with the request, the redirect
31
+ * response that was received, and the effective URI. Any return value
32
+ * from the on_redirect function is ignored.
33
+ */
34
+ const ALLOW_REDIRECTS = 'allow_redirects';
35
+
36
+ /**
37
+ * auth: (array) Pass an array of HTTP authentication parameters to use
38
+ * with the request. The array must contain the username in index [0],
39
+ * the password in index [1], and you can optionally provide a built-in
40
+ * authentication type in index [2]. Pass null to disable authentication
41
+ * for a request.
42
+ */
43
+ const AUTH = 'auth';
44
+
45
+ /**
46
+ * body: (string|null|callable|iterator|object) Body to send in the
47
+ * request.
48
+ */
49
+ const BODY = 'body';
50
+
51
+ /**
52
+ * cert: (string|array) Set to a string to specify the path to a file
53
+ * containing a PEM formatted SSL client side certificate. If a password
54
+ * is required, then set cert to an array containing the path to the PEM
55
+ * file in the first array element followed by the certificate password
56
+ * in the second array element.
57
+ */
58
+ const CERT = 'cert';
59
+
60
+ /**
61
+ * cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
62
+ * Specifies whether or not cookies are used in a request or what cookie
63
+ * jar to use or what cookies to send. This option only works if your
64
+ * handler has the `cookie` middleware. Valid values are `false` and
65
+ * an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}.
66
+ */
67
+ const COOKIES = 'cookies';
68
+
69
+ /**
70
+ * connect_timeout: (float, default=0) Float describing the number of
71
+ * seconds to wait while trying to connect to a server. Use 0 to wait
72
+ * indefinitely (the default behavior).
73
+ */
74
+ const CONNECT_TIMEOUT = 'connect_timeout';
75
+
76
+ /**
77
+ * debug: (bool|resource) Set to true or set to a PHP stream returned by
78
+ * fopen() enable debug output with the HTTP handler used to send a
79
+ * request.
80
+ */
81
+ const DEBUG = 'debug';
82
+
83
+ /**
84
+ * decode_content: (bool, default=true) Specify whether or not
85
+ * Content-Encoding responses (gzip, deflate, etc.) are automatically
86
+ * decoded.
87
+ */
88
+ const DECODE_CONTENT = 'decode_content';
89
+
90
+ /**
91
+ * delay: (int) The amount of time to delay before sending in milliseconds.
92
+ */
93
+ const DELAY = 'delay';
94
+
95
+ /**
96
+ * expect: (bool|integer) Controls the behavior of the
97
+ * "Expect: 100-Continue" header.
98
+ *
99
+ * Set to `true` to enable the "Expect: 100-Continue" header for all
100
+ * requests that sends a body. Set to `false` to disable the
101
+ * "Expect: 100-Continue" header for all requests. Set to a number so that
102
+ * the size of the payload must be greater than the number in order to send
103
+ * the Expect header. Setting to a number will send the Expect header for
104
+ * all requests in which the size of the payload cannot be determined or
105
+ * where the body is not rewindable.
106
+ *
107
+ * By default, Guzzle will add the "Expect: 100-Continue" header when the
108
+ * size of the body of a request is greater than 1 MB and a request is
109
+ * using HTTP/1.1.
110
+ */
111
+ const EXPECT = 'expect';
112
+
113
+ /**
114
+ * form_params: (array) Associative array of form field names to values
115
+ * where each value is a string or array of strings. Sets the Content-Type
116
+ * header to application/x-www-form-urlencoded when no Content-Type header
117
+ * is already present.
118
+ */
119
+ const FORM_PARAMS = 'form_params';
120
+
121
+ /**
122
+ * headers: (array) Associative array of HTTP headers. Each value MUST be
123
+ * a string or array of strings.
124
+ */
125
+ const HEADERS = 'headers';
126
+
127
+ /**
128
+ * http_errors: (bool, default=true) Set to false to disable exceptions
129
+ * when a non- successful HTTP response is received. By default,
130
+ * exceptions will be thrown for 4xx and 5xx responses. This option only
131
+ * works if your handler has the `httpErrors` middleware.
132
+ */
133
+ const HTTP_ERRORS = 'http_errors';
134
+
135
+ /**
136
+ * json: (mixed) Adds JSON data to a request. The provided value is JSON
137
+ * encoded and a Content-Type header of application/json will be added to
138
+ * the request if no Content-Type header is already present.
139
+ */
140
+ const JSON = 'json';
141
+
142
+ /**
143
+ * multipart: (array) Array of associative arrays, each containing a
144
+ * required "name" key mapping to the form field, name, a required
145
+ * "contents" key mapping to a StreamInterface|resource|string, an
146
+ * optional "headers" associative array of custom headers, and an
147
+ * optional "filename" key mapping to a string to send as the filename in
148
+ * the part. If no "filename" key is present, then no "filename" attribute
149
+ * will be added to the part.
150
+ */
151
+ const MULTIPART = 'multipart';
152
+
153
+ /**
154
+ * on_headers: (callable) A callable that is invoked when the HTTP headers
155
+ * of the response have been received but the body has not yet begun to
156
+ * download.
157
+ */
158
+ const ON_HEADERS = 'on_headers';
159
+
160
+ /**
161
+ * on_stats: (callable) allows you to get access to transfer statistics of
162
+ * a request and access the lower level transfer details of the handler
163
+ * associated with your client. ``on_stats`` is a callable that is invoked
164
+ * when a handler has finished sending a request. The callback is invoked
165
+ * with transfer statistics about the request, the response received, or
166
+ * the error encountered. Included in the data is the total amount of time
167
+ * taken to send the request.
168
+ */
169
+ const ON_STATS = 'on_stats';
170
+
171
+ /**
172
+ * progress: (callable) Defines a function to invoke when transfer
173
+ * progress is made. The function accepts the following positional
174
+ * arguments: the total number of bytes expected to be downloaded, the
175
+ * number of bytes downloaded so far, the number of bytes expected to be
176
+ * uploaded, the number of bytes uploaded so far.
177
+ */
178
+ const PROGRESS = 'progress';
179
+
180
+ /**
181
+ * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
182
+ * array to specify different proxies for different protocols (where the
183
+ * key is the protocol and the value is a proxy string).
184
+ */
185
+ const PROXY = 'proxy';
186
+
187
+ /**
188
+ * query: (array|string) Associative array of query string values to add
189
+ * to the request. This option uses PHP's http_build_query() to create
190
+ * the string representation. Pass a string value if you need more
191
+ * control than what this method provides
192
+ */
193
+ const QUERY = 'query';
194
+
195
+ /**
196
+ * sink: (resource|string|StreamInterface) Where the data of the
197
+ * response is written to. Defaults to a PHP temp stream. Providing a
198
+ * string will write data to a file by the given name.
199
+ */
200
+ const SINK = 'sink';
201
+
202
+ /**
203
+ * synchronous: (bool) Set to true to inform HTTP handlers that you intend
204
+ * on waiting on the response. This can be useful for optimizations. Note
205
+ * that a promise is still returned if you are using one of the async
206
+ * client methods.
207
+ */
208
+ const SYNCHRONOUS = 'synchronous';
209
+
210
+ /**
211
+ * ssl_key: (array|string) Specify the path to a file containing a private
212
+ * SSL key in PEM format. If a password is required, then set to an array
213
+ * containing the path to the SSL key in the first array element followed
214
+ * by the password required for the certificate in the second element.
215
+ */
216
+ const SSL_KEY = 'ssl_key';
217
+
218
+ /**
219
+ * stream: Set to true to attempt to stream a response rather than
220
+ * download it all up-front.
221
+ */
222
+ const STREAM = 'stream';
223
+
224
+ /**
225
+ * verify: (bool|string, default=true) Describes the SSL certificate
226
+ * verification behavior of a request. Set to true to enable SSL
227
+ * certificate verification using the system CA bundle when available
228
+ * (the default). Set to false to disable certificate verification (this
229
+ * is insecure!). Set to a string to provide the path to a CA bundle on
230
+ * disk to enable verification using a custom certificate.
231
+ */
232
+ const VERIFY = 'verify';
233
+
234
+ /**
235
+ * timeout: (float, default=0) Float describing the timeout of the
236
+ * request in seconds. Use 0 to wait indefinitely (the default behavior).
237
+ */
238
+ const TIMEOUT = 'timeout';
239
+
240
+ /**
241
+ * version: (float) Specifies the HTTP protocol version to attempt to use.
242
+ */
243
+ const VERSION = 'version';
244
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Promise\RejectedPromise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\RequestInterface;
8
+
9
+ /**
10
+ * Middleware that retries requests based on the boolean result of
11
+ * invoking the provided "decider" function.
12
+ */
13
+ class RetryMiddleware
14
+ {
15
+ /** @var callable */
16
+ private $nextHandler;
17
+
18
+ /** @var callable */
19
+ private $decider;
20
+
21
+ /**
22
+ * @param callable $decider Function that accepts the number of retries,
23
+ * a request, [response], and [exception] and
24
+ * returns true if the request is to be
25
+ * retried.
26
+ * @param callable $nextHandler Next handler to invoke.
27
+ * @param callable $delay Function that accepts the number of retries
28
+ * and returns the number of milliseconds to
29
+ * delay.
30
+ */
31
+ public function __construct(
32
+ callable $decider,
33
+ callable $nextHandler,
34
+ callable $delay = null
35
+ ) {
36
+ $this->decider = $decider;
37
+ $this->nextHandler = $nextHandler;
38
+ $this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
39
+ }
40
+
41
+ /**
42
+ * Default exponential backoff delay function.
43
+ *
44
+ * @param $retries
45
+ *
46
+ * @return int
47
+ */
48
+ public static function exponentialDelay($retries)
49
+ {
50
+ return (int) pow(2, $retries - 1);
51
+ }
52
+
53
+ /**
54
+ * @param RequestInterface $request
55
+ * @param array $options
56
+ *
57
+ * @return PromiseInterface
58
+ */
59
+ public function __invoke(RequestInterface $request, array $options)
60
+ {
61
+ if (!isset($options['retries'])) {
62
+ $options['retries'] = 0;
63
+ }
64
+
65
+ $fn = $this->nextHandler;
66
+ return $fn($request, $options)
67
+ ->then(
68
+ $this->onFulfilled($request, $options),
69
+ $this->onRejected($request, $options)
70
+ );
71
+ }
72
+
73
+ private function onFulfilled(RequestInterface $req, array $options)
74
+ {
75
+ return function ($value) use ($req, $options) {
76
+ if (!call_user_func(
77
+ $this->decider,
78
+ $options['retries'],
79
+ $req,
80
+ $value,
81
+ null
82
+ )) {
83
+ return $value;
84
+ }
85
+ return $this->doRetry($req, $options);
86
+ };
87
+ }
88
+
89
+ private function onRejected(RequestInterface $req, array $options)
90
+ {
91
+ return function ($reason) use ($req, $options) {
92
+ if (!call_user_func(
93
+ $this->decider,
94
+ $options['retries'],
95
+ $req,
96
+ null,
97
+ $reason
98
+ )) {
99
+ return new RejectedPromise($reason);
100
+ }
101
+ return $this->doRetry($req, $options);
102
+ };
103
+ }
104
+
105
+ private function doRetry(RequestInterface $request, array $options)
106
+ {
107
+ $options['delay'] = call_user_func($this->delay, ++$options['retries']);
108
+
109
+ return $this($request, $options);
110
+ }
111
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/TransferStats.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+ use Psr\Http\Message\UriInterface;
7
+
8
+ /**
9
+ * Represents data at the point after it was transferred either successfully
10
+ * or after a network error.
11
+ */
12
+ final class TransferStats
13
+ {
14
+ private $request;
15
+ private $response;
16
+ private $transferTime;
17
+ private $handlerStats;
18
+ private $handlerErrorData;
19
+
20
+ /**
21
+ * @param RequestInterface $request Request that was sent.
22
+ * @param ResponseInterface $response Response received (if any)
23
+ * @param null $transferTime Total handler transfer time.
24
+ * @param mixed $handlerErrorData Handler error data.
25
+ * @param array $handlerStats Handler specific stats.
26
+ */
27
+ public function __construct(
28
+ RequestInterface $request,
29
+ ResponseInterface $response = null,
30
+ $transferTime = null,
31
+ $handlerErrorData = null,
32
+ $handlerStats = []
33
+ ) {
34
+ $this->request = $request;
35
+ $this->response = $response;
36
+ $this->transferTime = $transferTime;
37
+ $this->handlerErrorData = $handlerErrorData;
38
+ $this->handlerStats = $handlerStats;
39
+ }
40
+
41
+ /**
42
+ * @return RequestInterface
43
+ */
44
+ public function getRequest()
45
+ {
46
+ return $this->request;
47
+ }
48
+
49
+ /**
50
+ * Returns the response that was received (if any).
51
+ *
52
+ * @return ResponseInterface|null
53
+ */
54
+ public function getResponse()
55
+ {
56
+ return $this->response;
57
+ }
58
+
59
+ /**
60
+ * Returns true if a response was received.
61
+ *
62
+ * @return bool
63
+ */
64
+ public function hasResponse()
65
+ {
66
+ return $this->response !== null;
67
+ }
68
+
69
+ /**
70
+ * Gets handler specific error data.
71
+ *
72
+ * This might be an exception, a integer representing an error code, or
73
+ * anything else. Relying on this value assumes that you know what handler
74
+ * you are using.
75
+ *
76
+ * @return mixed
77
+ */
78
+ public function getHandlerErrorData()
79
+ {
80
+ return $this->handlerErrorData;
81
+ }
82
+
83
+ /**
84
+ * Get the effective URI the request was sent to.
85
+ *
86
+ * @return UriInterface
87
+ */
88
+ public function getEffectiveUri()
89
+ {
90
+ return $this->request->getUri();
91
+ }
92
+
93
+ /**
94
+ * Get the estimated time the request was being transferred by the handler.
95
+ *
96
+ * @return float Time in seconds.
97
+ */
98
+ public function getTransferTime()
99
+ {
100
+ return $this->transferTime;
101
+ }
102
+
103
+ /**
104
+ * Gets an array of all of the handler specific transfer data.
105
+ *
106
+ * @return array
107
+ */
108
+ public function getHandlerStats()
109
+ {
110
+ return $this->handlerStats;
111
+ }
112
+
113
+ /**
114
+ * Get a specific handler statistic from the handler by name.
115
+ *
116
+ * @param string $stat Handler specific transfer stat to retrieve.
117
+ *
118
+ * @return mixed|null
119
+ */
120
+ public function getHandlerStat($stat)
121
+ {
122
+ return isset($this->handlerStats[$stat])
123
+ ? $this->handlerStats[$stat]
124
+ : null;
125
+ }
126
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/UriTemplate.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Expands URI templates. Userland implementation of PECL uri_template.
6
+ *
7
+ * @link http://tools.ietf.org/html/rfc6570
8
+ */
9
+ class UriTemplate
10
+ {
11
+ /** @var string URI template */
12
+ private $template;
13
+
14
+ /** @var array Variables to use in the template expansion */
15
+ private $variables;
16
+
17
+ /** @var array Hash for quick operator lookups */
18
+ private static $operatorHash = array(
19
+ '' => array('prefix' => '', 'joiner' => ',', 'query' => false),
20
+ '+' => array('prefix' => '', 'joiner' => ',', 'query' => false),
21
+ '#' => array('prefix' => '#', 'joiner' => ',', 'query' => false),
22
+ '.' => array('prefix' => '.', 'joiner' => '.', 'query' => false),
23
+ '/' => array('prefix' => '/', 'joiner' => '/', 'query' => false),
24
+ ';' => array('prefix' => ';', 'joiner' => ';', 'query' => true),
25
+ '?' => array('prefix' => '?', 'joiner' => '&', 'query' => true),
26
+ '&' => array('prefix' => '&', 'joiner' => '&', 'query' => true)
27
+ );
28
+
29
+ /** @var array Delimiters */
30
+ private static $delims = array(':', '/', '?', '#', '[', ']', '@', '!', '$',
31
+ '&', '\'', '(', ')', '*', '+', ',', ';', '=');
32
+
33
+ /** @var array Percent encoded delimiters */
34
+ private static $delimsPct = array('%3A', '%2F', '%3F', '%23', '%5B', '%5D',
35
+ '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C',
36
+ '%3B', '%3D');
37
+
38
+ public function expand($template, array $variables)
39
+ {
40
+ if (false === strpos($template, '{')) {
41
+ return $template;
42
+ }
43
+
44
+ $this->template = $template;
45
+ $this->variables = $variables;
46
+
47
+ return preg_replace_callback(
48
+ '/\{([^\}]+)\}/',
49
+ [$this, 'expandMatch'],
50
+ $this->template
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Parse an expression into parts
56
+ *
57
+ * @param string $expression Expression to parse
58
+ *
59
+ * @return array Returns an associative array of parts
60
+ */
61
+ private function parseExpression($expression)
62
+ {
63
+ $result = array();
64
+
65
+ if (isset(self::$operatorHash[$expression[0]])) {
66
+ $result['operator'] = $expression[0];
67
+ $expression = substr($expression, 1);
68
+ } else {
69
+ $result['operator'] = '';
70
+ }
71
+
72
+ foreach (explode(',', $expression) as $value) {
73
+ $value = trim($value);
74
+ $varspec = array();
75
+ if ($colonPos = strpos($value, ':')) {
76
+ $varspec['value'] = substr($value, 0, $colonPos);
77
+ $varspec['modifier'] = ':';
78
+ $varspec['position'] = (int) substr($value, $colonPos + 1);
79
+ } elseif (substr($value, -1) == '*') {
80
+ $varspec['modifier'] = '*';
81
+ $varspec['value'] = substr($value, 0, -1);
82
+ } else {
83
+ $varspec['value'] = (string) $value;
84
+ $varspec['modifier'] = '';
85
+ }
86
+ $result['values'][] = $varspec;
87
+ }
88
+
89
+ return $result;
90
+ }
91
+
92
+ /**
93
+ * Process an expansion
94
+ *
95
+ * @param array $matches Matches met in the preg_replace_callback
96
+ *
97
+ * @return string Returns the replacement string
98
+ */
99
+ private function expandMatch(array $matches)
100
+ {
101
+ static $rfc1738to3986 = array('+' => '%20', '%7e' => '~');
102
+
103
+ $replacements = array();
104
+ $parsed = self::parseExpression($matches[1]);
105
+ $prefix = self::$operatorHash[$parsed['operator']]['prefix'];
106
+ $joiner = self::$operatorHash[$parsed['operator']]['joiner'];
107
+ $useQuery = self::$operatorHash[$parsed['operator']]['query'];
108
+
109
+ foreach ($parsed['values'] as $value) {
110
+
111
+ if (!isset($this->variables[$value['value']])) {
112
+ continue;
113
+ }
114
+
115
+ $variable = $this->variables[$value['value']];
116
+ $actuallyUseQuery = $useQuery;
117
+ $expanded = '';
118
+
119
+ if (is_array($variable)) {
120
+
121
+ $isAssoc = $this->isAssoc($variable);
122
+ $kvp = array();
123
+ foreach ($variable as $key => $var) {
124
+
125
+ if ($isAssoc) {
126
+ $key = rawurlencode($key);
127
+ $isNestedArray = is_array($var);
128
+ } else {
129
+ $isNestedArray = false;
130
+ }
131
+
132
+ if (!$isNestedArray) {
133
+ $var = rawurlencode($var);
134
+ if ($parsed['operator'] == '+' ||
135
+ $parsed['operator'] == '#'
136
+ ) {
137
+ $var = $this->decodeReserved($var);
138
+ }
139
+ }
140
+
141
+ if ($value['modifier'] == '*') {
142
+ if ($isAssoc) {
143
+ if ($isNestedArray) {
144
+ // Nested arrays must allow for deeply nested
145
+ // structures.
146
+ $var = strtr(
147
+ http_build_query([$key => $var]),
148
+ $rfc1738to3986
149
+ );
150
+ } else {
151
+ $var = $key . '=' . $var;
152
+ }
153
+ } elseif ($key > 0 && $actuallyUseQuery) {
154
+ $var = $value['value'] . '=' . $var;
155
+ }
156
+ }
157
+
158
+ $kvp[$key] = $var;
159
+ }
160
+
161
+ if (empty($variable)) {
162
+ $actuallyUseQuery = false;
163
+ } elseif ($value['modifier'] == '*') {
164
+ $expanded = implode($joiner, $kvp);
165
+ if ($isAssoc) {
166
+ // Don't prepend the value name when using the explode
167
+ // modifier with an associative array.
168
+ $actuallyUseQuery = false;
169
+ }
170
+ } else {
171
+ if ($isAssoc) {
172
+ // When an associative array is encountered and the
173
+ // explode modifier is not set, then the result must be
174
+ // a comma separated list of keys followed by their
175
+ // respective values.
176
+ foreach ($kvp as $k => &$v) {
177
+ $v = $k . ',' . $v;
178
+ }
179
+ }
180
+ $expanded = implode(',', $kvp);
181
+ }
182
+
183
+ } else {
184
+ if ($value['modifier'] == ':') {
185
+ $variable = substr($variable, 0, $value['position']);
186
+ }
187
+ $expanded = rawurlencode($variable);
188
+ if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
189
+ $expanded = $this->decodeReserved($expanded);
190
+ }
191
+ }
192
+
193
+ if ($actuallyUseQuery) {
194
+ if (!$expanded && $joiner != '&') {
195
+ $expanded = $value['value'];
196
+ } else {
197
+ $expanded = $value['value'] . '=' . $expanded;
198
+ }
199
+ }
200
+
201
+ $replacements[] = $expanded;
202
+ }
203
+
204
+ $ret = implode($joiner, $replacements);
205
+ if ($ret && $prefix) {
206
+ return $prefix . $ret;
207
+ }
208
+
209
+ return $ret;
210
+ }
211
+
212
+ /**
213
+ * Determines if an array is associative.
214
+ *
215
+ * This makes the assumption that input arrays are sequences or hashes.
216
+ * This assumption is a tradeoff for accuracy in favor of speed, but it
217
+ * should work in almost every case where input is supplied for a URI
218
+ * template.
219
+ *
220
+ * @param array $array Array to check
221
+ *
222
+ * @return bool
223
+ */
224
+ private function isAssoc(array $array)
225
+ {
226
+ return $array && array_keys($array)[0] !== 0;
227
+ }
228
+
229
+ /**
230
+ * Removes percent encoding on reserved characters (used with + and #
231
+ * modifiers).
232
+ *
233
+ * @param string $string String to fix
234
+ *
235
+ * @return string
236
+ */
237
+ private function decodeReserved($string)
238
+ {
239
+ return str_replace(self::$delimsPct, self::$delims, $string);
240
+ }
241
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/functions.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Handler\CurlHandler;
5
+ use GuzzleHttp\Handler\CurlMultiHandler;
6
+ use GuzzleHttp\Handler\Proxy;
7
+ use GuzzleHttp\Handler\StreamHandler;
8
+ use Psr\Http\Message\StreamInterface;
9
+
10
+ /**
11
+ * Expands a URI template
12
+ *
13
+ * @param string $template URI template
14
+ * @param array $variables Template variables
15
+ *
16
+ * @return string
17
+ */
18
+ function uri_template($template, array $variables)
19
+ {
20
+ if (extension_loaded('uri_template')) {
21
+ // @codeCoverageIgnoreStart
22
+ return \uri_template($template, $variables);
23
+ // @codeCoverageIgnoreEnd
24
+ }
25
+
26
+ static $uriTemplate;
27
+ if (!$uriTemplate) {
28
+ $uriTemplate = new UriTemplate();
29
+ }
30
+
31
+ return $uriTemplate->expand($template, $variables);
32
+ }
33
+
34
+ /**
35
+ * Debug function used to describe the provided value type and class.
36
+ *
37
+ * @param mixed $input
38
+ *
39
+ * @return string Returns a string containing the type of the variable and
40
+ * if a class is provided, the class name.
41
+ */
42
+ function describe_type($input)
43
+ {
44
+ switch (gettype($input)) {
45
+ case 'object':
46
+ return 'object(' . get_class($input) . ')';
47
+ case 'array':
48
+ return 'array(' . count($input) . ')';
49
+ default:
50
+ ob_start();
51
+ var_dump($input);
52
+ // normalize float vs double
53
+ return str_replace('double(', 'float(', rtrim(ob_get_clean()));
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Parses an array of header lines into an associative array of headers.
59
+ *
60
+ * @param array $lines Header lines array of strings in the following
61
+ * format: "Name: Value"
62
+ * @return array
63
+ */
64
+ function headers_from_lines($lines)
65
+ {
66
+ $headers = [];
67
+
68
+ foreach ($lines as $line) {
69
+ $parts = explode(':', $line, 2);
70
+ $headers[trim($parts[0])][] = isset($parts[1])
71
+ ? trim($parts[1])
72
+ : null;
73
+ }
74
+
75
+ return $headers;
76
+ }
77
+
78
+ /**
79
+ * Returns a debug stream based on the provided variable.
80
+ *
81
+ * @param mixed $value Optional value
82
+ *
83
+ * @return resource
84
+ */
85
+ function debug_resource($value = null)
86
+ {
87
+ if (is_resource($value)) {
88
+ return $value;
89
+ } elseif (defined('STDOUT')) {
90
+ return STDOUT;
91
+ }
92
+
93
+ return fopen('php://output', 'w');
94
+ }
95
+
96
+ /**
97
+ * Chooses and creates a default handler to use based on the environment.
98
+ *
99
+ * The returned handler is not wrapped by any default middlewares.
100
+ *
101
+ * @throws \RuntimeException if no viable Handler is available.
102
+ * @return callable Returns the best handler for the given system.
103
+ */
104
+ function choose_handler()
105
+ {
106
+ $handler = null;
107
+ if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
108
+ $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
109
+ } elseif (function_exists('curl_exec')) {
110
+ $handler = new CurlHandler();
111
+ } elseif (function_exists('curl_multi_exec')) {
112
+ $handler = new CurlMultiHandler();
113
+ }
114
+
115
+ if (ini_get('allow_url_fopen')) {
116
+ $handler = $handler
117
+ ? Proxy::wrapStreaming($handler, new StreamHandler())
118
+ : new StreamHandler();
119
+ } elseif (!$handler) {
120
+ throw new \RuntimeException('GuzzleHttp requires cURL, the '
121
+ . 'allow_url_fopen ini setting, or a custom HTTP handler.');
122
+ }
123
+
124
+ return $handler;
125
+ }
126
+
127
+ /**
128
+ * Get the default User-Agent string to use with Guzzle
129
+ *
130
+ * @return string
131
+ */
132
+ function default_user_agent()
133
+ {
134
+ static $defaultAgent = '';
135
+
136
+ if (!$defaultAgent) {
137
+ $defaultAgent = 'GuzzleHttp/' . Client::VERSION;
138
+ if (extension_loaded('curl') && function_exists('curl_version')) {
139
+ $defaultAgent .= ' curl/' . \curl_version()['version'];
140
+ }
141
+ $defaultAgent .= ' PHP/' . PHP_VERSION;
142
+ }
143
+
144
+ return $defaultAgent;
145
+ }
146
+
147
+ /**
148
+ * Returns the default cacert bundle for the current system.
149
+ *
150
+ * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
151
+ * If those settings are not configured, then the common locations for
152
+ * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
153
+ * and Windows are checked. If any of these file locations are found on
154
+ * disk, they will be utilized.
155
+ *
156
+ * Note: the result of this function is cached for subsequent calls.
157
+ *
158
+ * @return string
159
+ * @throws \RuntimeException if no bundle can be found.
160
+ */
161
+ function default_ca_bundle()
162
+ {
163
+ static $cached = null;
164
+ static $cafiles = [
165
+ // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
166
+ '/etc/pki/tls/certs/ca-bundle.crt',
167
+ // Ubuntu, Debian (provided by the ca-certificates package)
168
+ '/etc/ssl/certs/ca-certificates.crt',
169
+ // FreeBSD (provided by the ca_root_nss package)
170
+ '/usr/local/share/certs/ca-root-nss.crt',
171
+ // OS X provided by homebrew (using the default path)
172
+ '/usr/local/etc/openssl/cert.pem',
173
+ // Google app engine
174
+ '/etc/ca-certificates.crt',
175
+ // Windows?
176
+ 'C:\\windows\\system32\\curl-ca-bundle.crt',
177
+ 'C:\\windows\\curl-ca-bundle.crt',
178
+ ];
179
+
180
+ if ($cached) {
181
+ return $cached;
182
+ }
183
+
184
+ if ($ca = ini_get('openssl.cafile')) {
185
+ return $cached = $ca;
186
+ }
187
+
188
+ if ($ca = ini_get('curl.cainfo')) {
189
+ return $cached = $ca;
190
+ }
191
+
192
+ foreach ($cafiles as $filename) {
193
+ if (file_exists($filename)) {
194
+ return $cached = $filename;
195
+ }
196
+ }
197
+
198
+ throw new \RuntimeException(<<< EOT
199
+ No system CA bundle could be found in any of the the common system locations.
200
+ PHP versions earlier than 5.6 are not properly configured to use the system's
201
+ CA bundle by default. In order to verify peer certificates, you will need to
202
+ supply the path on disk to a certificate bundle to the 'verify' request
203
+ option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
204
+ need a specific certificate bundle, then Mozilla provides a commonly used CA
205
+ bundle which can be downloaded here (provided by the maintainer of cURL):
206
+ https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once
207
+ you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
208
+ ini setting to point to the path to the file, allowing you to omit the 'verify'
209
+ request option. See http://curl.haxx.se/docs/sslcerts.html for more
210
+ information.
211
+ EOT
212
+ );
213
+ }
214
+
215
+ /**
216
+ * Creates an associative array of lowercase header names to the actual
217
+ * header casing.
218
+ *
219
+ * @param array $headers
220
+ *
221
+ * @return array
222
+ */
223
+ function normalize_header_keys(array $headers)
224
+ {
225
+ $result = [];
226
+ foreach (array_keys($headers) as $key) {
227
+ $result[strtolower($key)] = $key;
228
+ }
229
+
230
+ return $result;
231
+ }
232
+
233
+ /**
234
+ * Returns true if the provided host matches any of the no proxy areas.
235
+ *
236
+ * This method will strip a port from the host if it is present. Each pattern
237
+ * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
238
+ * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
239
+ * "baz.foo.com", but ".foo.com" != "foo.com").
240
+ *
241
+ * Areas are matched in the following cases:
242
+ * 1. "*" (without quotes) always matches any hosts.
243
+ * 2. An exact match.
244
+ * 3. The area starts with "." and the area is the last part of the host. e.g.
245
+ * '.mit.edu' will match any host that ends with '.mit.edu'.
246
+ *
247
+ * @param string $host Host to check against the patterns.
248
+ * @param array $noProxyArray An array of host patterns.
249
+ *
250
+ * @return bool
251
+ */
252
+ function is_host_in_noproxy($host, array $noProxyArray)
253
+ {
254
+ if (strlen($host) === 0) {
255
+ throw new \InvalidArgumentException('Empty host provided');
256
+ }
257
+
258
+ // Strip port if present.
259
+ if (strpos($host, ':')) {
260
+ $host = explode($host, ':', 2)[0];
261
+ }
262
+
263
+ foreach ($noProxyArray as $area) {
264
+ // Always match on wildcards.
265
+ if ($area === '*') {
266
+ return true;
267
+ } elseif (empty($area)) {
268
+ // Don't match on empty values.
269
+ continue;
270
+ } elseif ($area === $host) {
271
+ // Exact matches.
272
+ return true;
273
+ } else {
274
+ // Special match if the area when prefixed with ".". Remove any
275
+ // existing leading "." and add a new leading ".".
276
+ $area = '.' . ltrim($area, '.');
277
+ if (substr($host, -(strlen($area))) === $area) {
278
+ return true;
279
+ }
280
+ }
281
+ }
282
+
283
+ return false;
284
+ }
285
+
286
+ /**
287
+ * Wrapper for json_decode that throws when an error occurs.
288
+ *
289
+ * @param string $json JSON data to parse
290
+ * @param bool $assoc When true, returned objects will be converted
291
+ * into associative arrays.
292
+ * @param int $depth User specified recursion depth.
293
+ * @param int $options Bitmask of JSON decode options.
294
+ *
295
+ * @return mixed
296
+ * @throws \InvalidArgumentException if the JSON cannot be decoded.
297
+ * @link http://www.php.net/manual/en/function.json-decode.php
298
+ */
299
+ function json_decode($json, $assoc = false, $depth = 512, $options = 0)
300
+ {
301
+ $data = \json_decode($json, $assoc, $depth, $options);
302
+ if (JSON_ERROR_NONE !== json_last_error()) {
303
+ throw new \InvalidArgumentException(
304
+ 'json_decode error: ' . json_last_error_msg());
305
+ }
306
+
307
+ return $data;
308
+ }
309
+
310
+ /**
311
+ * Wrapper for JSON encoding that throws when an error occurs.
312
+ *
313
+ * @param string $value The value being encoded
314
+ * @param int $options JSON encode option bitmask
315
+ * @param int $depth Set the maximum depth. Must be greater than zero.
316
+ *
317
+ * @return string
318
+ * @throws \InvalidArgumentException if the JSON cannot be encoded.
319
+ * @link http://www.php.net/manual/en/function.json-encode.php
320
+ */
321
+ function json_encode($value, $options = 0, $depth = 512)
322
+ {
323
+ $json = \json_encode($value, $options, $depth);
324
+ if (JSON_ERROR_NONE !== json_last_error()) {
325
+ throw new \InvalidArgumentException(
326
+ 'json_encode error: ' . json_last_error_msg());
327
+ }
328
+
329
+ return $json;
330
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/guzzle/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\uri_template')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 1.2.0 - 2016-05-18
4
+
5
+ * Update to now catch `\Throwable` on PHP 7+
6
+
7
+ ## 1.1.0 - 2016-03-07
8
+
9
+ * Update EachPromise to prevent recurring on a iterator when advancing, as this
10
+ could trigger fatal generator errors.
11
+ * Update Promise to allow recursive waiting without unwrapping exceptions.
12
+
13
+ ## 1.0.3 - 2015-10-15
14
+
15
+ * Update EachPromise to immediately resolve when the underlying promise iterator
16
+ is empty. Previously, such a promise would throw an exception when its `wait`
17
+ function was called.
18
+
19
+ ## 1.0.2 - 2015-05-15
20
+
21
+ * Conditionally require functions.php.
22
+
23
+ ## 1.0.1 - 2015-06-24
24
+
25
+ * Updating EachPromise to call next on the underlying promise iterator as late
26
+ as possible to ensure that generators that generate new requests based on
27
+ callbacks are not iterated until after callbacks are invoked.
28
+
29
+ ## 1.0.0 - 2015-05-12
30
+
31
+ * Initial release
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/Makefile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ clean:
13
+ rm -rf artifacts/*
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/README.md ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Guzzle Promises
2
+
3
+ [Promises/A+](https://promisesaplus.com/) implementation that handles promise
4
+ chaining and resolution iteratively, allowing for "infinite" promise chaining
5
+ while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/)
6
+ for a general introduction to promises.
7
+
8
+ - [Features](#features)
9
+ - [Quick start](#quick-start)
10
+ - [Synchronous wait](#synchronous-wait)
11
+ - [Cancellation](#cancellation)
12
+ - [API](#api)
13
+ - [Promise](#promise)
14
+ - [FulfilledPromise](#fulfilledpromise)
15
+ - [RejectedPromise](#rejectedpromise)
16
+ - [Promise interop](#promise-interop)
17
+ - [Implementation notes](#implementation-notes)
18
+
19
+
20
+ # Features
21
+
22
+ - [Promises/A+](https://promisesaplus.com/) implementation.
23
+ - Promise resolution and chaining is handled iteratively, allowing for
24
+ "infinite" promise chaining.
25
+ - Promises have a synchronous `wait` method.
26
+ - Promises can be cancelled.
27
+ - Works with any object that has a `then` function.
28
+ - C# style async/await coroutine promises using
29
+ `GuzzleHttp\Promise\coroutine()`.
30
+
31
+
32
+ # Quick start
33
+
34
+ A *promise* represents the eventual result of an asynchronous operation. The
35
+ primary way of interacting with a promise is through its `then` method, which
36
+ registers callbacks to receive either a promise's eventual value or the reason
37
+ why the promise cannot be fulfilled.
38
+
39
+
40
+ ## Callbacks
41
+
42
+ Callbacks are registered with the `then` method by providing an optional
43
+ `$onFulfilled` followed by an optional `$onRejected` function.
44
+
45
+
46
+ ```php
47
+ use GuzzleHttp\Promise\Promise;
48
+
49
+ $promise = new Promise();
50
+ $promise->then(
51
+ // $onFulfilled
52
+ function ($value) {
53
+ echo 'The promise was fulfilled.';
54
+ },
55
+ // $onRejected
56
+ function ($reason) {
57
+ echo 'The promise was rejected.';
58
+ }
59
+ );
60
+ ```
61
+
62
+ *Resolving* a promise means that you either fulfill a promise with a *value* or
63
+ reject a promise with a *reason*. Resolving a promises triggers callbacks
64
+ registered with the promises's `then` method. These callbacks are triggered
65
+ only once and in the order in which they were added.
66
+
67
+
68
+ ## Resolving a promise
69
+
70
+ Promises are fulfilled using the `resolve($value)` method. Resolving a promise
71
+ with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger
72
+ all of the onFulfilled callbacks (resolving a promise with a rejected promise
73
+ will reject the promise and trigger the `$onRejected` callbacks).
74
+
75
+ ```php
76
+ use GuzzleHttp\Promise\Promise;
77
+
78
+ $promise = new Promise();
79
+ $promise
80
+ ->then(function ($value) {
81
+ // Return a value and don't break the chain
82
+ return "Hello, " . $value;
83
+ })
84
+ // This then is executed after the first then and receives the value
85
+ // returned from the first then.
86
+ ->then(function ($value) {
87
+ echo $value;
88
+ });
89
+
90
+ // Resolving the promise triggers the $onFulfilled callbacks and outputs
91
+ // "Hello, reader".
92
+ $promise->resolve('reader.');
93
+ ```
94
+
95
+
96
+ ## Promise forwarding
97
+
98
+ Promises can be chained one after the other. Each then in the chain is a new
99
+ promise. The return value of of a promise is what's forwarded to the next
100
+ promise in the chain. Returning a promise in a `then` callback will cause the
101
+ subsequent promises in the chain to only be fulfilled when the returned promise
102
+ has been fulfilled. The next promise in the chain will be invoked with the
103
+ resolved value of the promise.
104
+
105
+ ```php
106
+ use GuzzleHttp\Promise\Promise;
107
+
108
+ $promise = new Promise();
109
+ $nextPromise = new Promise();
110
+
111
+ $promise
112
+ ->then(function ($value) use ($nextPromise) {
113
+ echo $value;
114
+ return $nextPromise;
115
+ })
116
+ ->then(function ($value) {
117
+ echo $value;
118
+ });
119
+
120
+ // Triggers the first callback and outputs "A"
121
+ $promise->resolve('A');
122
+ // Triggers the second callback and outputs "B"
123
+ $nextPromise->resolve('B');
124
+ ```
125
+
126
+ ## Promise rejection
127
+
128
+ When a promise is rejected, the `$onRejected` callbacks are invoked with the
129
+ rejection reason.
130
+
131
+ ```php
132
+ use GuzzleHttp\Promise\Promise;
133
+
134
+ $promise = new Promise();
135
+ $promise->then(null, function ($reason) {
136
+ echo $reason;
137
+ });
138
+
139
+ $promise->reject('Error!');
140
+ // Outputs "Error!"
141
+ ```
142
+
143
+ ## Rejection forwarding
144
+
145
+ If an exception is thrown in an `$onRejected` callback, subsequent
146
+ `$onRejected` callbacks are invoked with the thrown exception as the reason.
147
+
148
+ ```php
149
+ use GuzzleHttp\Promise\Promise;
150
+
151
+ $promise = new Promise();
152
+ $promise->then(null, function ($reason) {
153
+ throw new \Exception($reason);
154
+ })->then(null, function ($reason) {
155
+ assert($reason->getMessage() === 'Error!');
156
+ });
157
+
158
+ $promise->reject('Error!');
159
+ ```
160
+
161
+ You can also forward a rejection down the promise chain by returning a
162
+ `GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or
163
+ `$onRejected` callback.
164
+
165
+ ```php
166
+ use GuzzleHttp\Promise\Promise;
167
+ use GuzzleHttp\Promise\RejectedPromise;
168
+
169
+ $promise = new Promise();
170
+ $promise->then(null, function ($reason) {
171
+ return new RejectedPromise($reason);
172
+ })->then(null, function ($reason) {
173
+ assert($reason === 'Error!');
174
+ });
175
+
176
+ $promise->reject('Error!');
177
+ ```
178
+
179
+ If an exception is not thrown in a `$onRejected` callback and the callback
180
+ does not return a rejected promise, downstream `$onFulfilled` callbacks are
181
+ invoked using the value returned from the `$onRejected` callback.
182
+
183
+ ```php
184
+ use GuzzleHttp\Promise\Promise;
185
+ use GuzzleHttp\Promise\RejectedPromise;
186
+
187
+ $promise = new Promise();
188
+ $promise
189
+ ->then(null, function ($reason) {
190
+ return "It's ok";
191
+ })
192
+ ->then(function ($value) {
193
+ assert($value === "It's ok");
194
+ });
195
+
196
+ $promise->reject('Error!');
197
+ ```
198
+
199
+ # Synchronous wait
200
+
201
+ You can synchronously force promises to complete using a promise's `wait`
202
+ method. When creating a promise, you can provide a wait function that is used
203
+ to synchronously force a promise to complete. When a wait function is invoked
204
+ it is expected to deliver a value to the promise or reject the promise. If the
205
+ wait function does not deliver a value, then an exception is thrown. The wait
206
+ function provided to a promise constructor is invoked when the `wait` function
207
+ of the promise is called.
208
+
209
+ ```php
210
+ $promise = new Promise(function () use (&$promise) {
211
+ $promise->resolve('foo');
212
+ });
213
+
214
+ // Calling wait will return the value of the promise.
215
+ echo $promise->wait(); // outputs "foo"
216
+ ```
217
+
218
+ If an exception is encountered while invoking the wait function of a promise,
219
+ the promise is rejected with the exception and the exception is thrown.
220
+
221
+ ```php
222
+ $promise = new Promise(function () use (&$promise) {
223
+ throw new \Exception('foo');
224
+ });
225
+
226
+ $promise->wait(); // throws the exception.
227
+ ```
228
+
229
+ Calling `wait` on a promise that has been fulfilled will not trigger the wait
230
+ function. It will simply return the previously resolved value.
231
+
232
+ ```php
233
+ $promise = new Promise(function () { die('this is not called!'); });
234
+ $promise->resolve('foo');
235
+ echo $promise->wait(); // outputs "foo"
236
+ ```
237
+
238
+ Calling `wait` on a promise that has been rejected will throw an exception. If
239
+ the rejection reason is an instance of `\Exception` the reason is thrown.
240
+ Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason
241
+ can be obtained by calling the `getReason` method of the exception.
242
+
243
+ ```php
244
+ $promise = new Promise();
245
+ $promise->reject('foo');
246
+ $promise->wait();
247
+ ```
248
+
249
+ > PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo'
250
+
251
+
252
+ ## Unwrapping a promise
253
+
254
+ When synchronously waiting on a promise, you are joining the state of the
255
+ promise into the current state of execution (i.e., return the value of the
256
+ promise if it was fulfilled or throw an exception if it was rejected). This is
257
+ called "unwrapping" the promise. Waiting on a promise will by default unwrap
258
+ the promise state.
259
+
260
+ You can force a promise to resolve and *not* unwrap the state of the promise
261
+ by passing `false` to the first argument of the `wait` function:
262
+
263
+ ```php
264
+ $promise = new Promise();
265
+ $promise->reject('foo');
266
+ // This will not throw an exception. It simply ensures the promise has
267
+ // been resolved.
268
+ $promise->wait(false);
269
+ ```
270
+
271
+ When unwrapping a promise, the resolved value of the promise will be waited
272
+ upon until the unwrapped value is not a promise. This means that if you resolve
273
+ promise A with a promise B and unwrap promise A, the value returned by the
274
+ wait function will be the value delivered to promise B.
275
+
276
+ **Note**: when you do not unwrap the promise, no value is returned.
277
+
278
+
279
+ # Cancellation
280
+
281
+ You can cancel a promise that has not yet been fulfilled using the `cancel()`
282
+ method of a promise. When creating a promise you can provide an optional
283
+ cancel function that when invoked cancels the action of computing a resolution
284
+ of the promise.
285
+
286
+
287
+ # API
288
+
289
+
290
+ ## Promise
291
+
292
+ When creating a promise object, you can provide an optional `$waitFn` and
293
+ `$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is
294
+ expected to resolve the promise. `$cancelFn` is a function with no arguments
295
+ that is expected to cancel the computation of a promise. It is invoked when the
296
+ `cancel()` method of a promise is called.
297
+
298
+ ```php
299
+ use GuzzleHttp\Promise\Promise;
300
+
301
+ $promise = new Promise(
302
+ function () use (&$promise) {
303
+ $promise->resolve('waited');
304
+ },
305
+ function () {
306
+ // do something that will cancel the promise computation (e.g., close
307
+ // a socket, cancel a database query, etc...)
308
+ }
309
+ );
310
+
311
+ assert('waited' === $promise->wait());
312
+ ```
313
+
314
+ A promise has the following methods:
315
+
316
+ - `then(callable $onFulfilled, callable $onRejected) : PromiseInterface`
317
+
318
+ Creates a new promise that is fulfilled or rejected when the promise is
319
+ resolved.
320
+
321
+ - `wait($unwrap = true) : mixed`
322
+
323
+ Synchronously waits on the promise to complete.
324
+
325
+ `$unwrap` controls whether or not the value of the promise is returned for a
326
+ fulfilled promise or if an exception is thrown if the promise is rejected.
327
+ This is set to `true` by default.
328
+
329
+ - `cancel()`
330
+
331
+ Attempts to cancel the promise if possible. The promise being cancelled and
332
+ the parent most ancestor that has not yet been resolved will also be
333
+ cancelled. Any promises waiting on the cancelled promise to resolve will also
334
+ be cancelled.
335
+
336
+ - `getState() : string`
337
+
338
+ Returns the state of the promise. One of `pending`, `fulfilled`, or
339
+ `rejected`.
340
+
341
+ - `resolve($value)`
342
+
343
+ Fulfills the promise with the given `$value`.
344
+
345
+ - `reject($reason)`
346
+
347
+ Rejects the promise with the given `$reason`.
348
+
349
+
350
+ ## FulfilledPromise
351
+
352
+ A fulfilled promise can be created to represent a promise that has been
353
+ fulfilled.
354
+
355
+ ```php
356
+ use GuzzleHttp\Promise\FulfilledPromise;
357
+
358
+ $promise = new FulfilledPromise('value');
359
+
360
+ // Fulfilled callbacks are immediately invoked.
361
+ $promise->then(function ($value) {
362
+ echo $value;
363
+ });
364
+ ```
365
+
366
+
367
+ ## RejectedPromise
368
+
369
+ A rejected promise can be created to represent a promise that has been
370
+ rejected.
371
+
372
+ ```php
373
+ use GuzzleHttp\Promise\RejectedPromise;
374
+
375
+ $promise = new RejectedPromise('Error');
376
+
377
+ // Rejected callbacks are immediately invoked.
378
+ $promise->then(null, function ($reason) {
379
+ echo $reason;
380
+ });
381
+ ```
382
+
383
+
384
+ # Promise interop
385
+
386
+ This library works with foreign promises that have a `then` method. This means
387
+ you can use Guzzle promises with [React promises](https://github.com/reactphp/promise)
388
+ for example. When a foreign promise is returned inside of a then method
389
+ callback, promise resolution will occur recursively.
390
+
391
+ ```php
392
+ // Create a React promise
393
+ $deferred = new React\Promise\Deferred();
394
+ $reactPromise = $deferred->promise();
395
+
396
+ // Create a Guzzle promise that is fulfilled with a React promise.
397
+ $guzzlePromise = new \GuzzleHttp\Promise\Promise();
398
+ $guzzlePromise->then(function ($value) use ($reactPromise) {
399
+ // Do something something with the value...
400
+ // Return the React promise
401
+ return $reactPromise;
402
+ });
403
+ ```
404
+
405
+ Please note that wait and cancel chaining is no longer possible when forwarding
406
+ a foreign promise. You will need to wrap a third-party promise with a Guzzle
407
+ promise in order to utilize wait and cancel functions with foreign promises.
408
+
409
+
410
+ ## Event Loop Integration
411
+
412
+ In order to keep the stack size constant, Guzzle promises are resolved
413
+ asynchronously using a task queue. When waiting on promises synchronously, the
414
+ task queue will be automatically run to ensure that the blocking promise and
415
+ any forwarded promises are resolved. When using promises asynchronously in an
416
+ event loop, you will need to run the task queue on each tick of the loop. If
417
+ you do not run the task queue, then promises will not be resolved.
418
+
419
+ You can run the task queue using the `run()` method of the global task queue
420
+ instance.
421
+
422
+ ```php
423
+ // Get the global task queue
424
+ $queue = \GuzzleHttp\Promise\queue();
425
+ $queue->run();
426
+ ```
427
+
428
+ For example, you could use Guzzle promises with React using a periodic timer:
429
+
430
+ ```php
431
+ $loop = React\EventLoop\Factory::create();
432
+ $loop->addPeriodicTimer(0, [$queue, 'run']);
433
+ ```
434
+
435
+ *TODO*: Perhaps adding a `futureTick()` on each tick would be faster?
436
+
437
+
438
+ # Implementation notes
439
+
440
+
441
+ ## Promise resolution and chaining is handled iteratively
442
+
443
+ By shuffling pending handlers from one owner to another, promises are
444
+ resolved iteratively, allowing for "infinite" then chaining.
445
+
446
+ ```php
447
+ <?php
448
+ require 'vendor/autoload.php';
449
+
450
+ use GuzzleHttp\Promise\Promise;
451
+
452
+ $parent = new Promise();
453
+ $p = $parent;
454
+
455
+ for ($i = 0; $i < 1000; $i++) {
456
+ $p = $p->then(function ($v) {
457
+ // The stack size remains constant (a good thing)
458
+ echo xdebug_get_stack_depth() . ', ';
459
+ return $v + 1;
460
+ });
461
+ }
462
+
463
+ $parent->resolve(0);
464
+ var_dump($p->wait()); // int(1000)
465
+
466
+ ```
467
+
468
+ When a promise is fulfilled or rejected with a non-promise value, the promise
469
+ then takes ownership of the handlers of each child promise and delivers values
470
+ down the chain without using recursion.
471
+
472
+ When a promise is resolved with another promise, the original promise transfers
473
+ all of its pending handlers to the new promise. When the new promise is
474
+ eventually resolved, all of the pending handlers are delivered the forwarded
475
+ value.
476
+
477
+
478
+ ## A promise is the deferred.
479
+
480
+ Some promise libraries implement promises using a deferred object to represent
481
+ a computation and a promise object to represent the delivery of the result of
482
+ the computation. This is a nice separation of computation and delivery because
483
+ consumers of the promise cannot modify the value that will be eventually
484
+ delivered.
485
+
486
+ One side effect of being able to implement promise resolution and chaining
487
+ iteratively is that you need to be able for one promise to reach into the state
488
+ of another promise to shuffle around ownership of handlers. In order to achieve
489
+ this without making the handlers of a promise publicly mutable, a promise is
490
+ also the deferred value, allowing promises of the same parent class to reach
491
+ into and modify the private properties of promises of the same type. While this
492
+ does allow consumers of the value to modify the resolution or rejection of the
493
+ deferred, it is a small price to pay for keeping the stack size constant.
494
+
495
+ ```php
496
+ $promise = new Promise();
497
+ $promise->then(function ($value) { echo $value; });
498
+ // The promise is the deferred value, so you can deliver a value to it.
499
+ $promise->resolve('foo');
500
+ // prints "foo"
501
+ ```
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/composer.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/promises",
3
+ "type": "library",
4
+ "description": "Guzzle promises library",
5
+ "keywords": ["promise"],
6
+ "license": "MIT",
7
+ "authors": [
8
+ {
9
+ "name": "Michael Dowling",
10
+ "email": "mtdowling@gmail.com",
11
+ "homepage": "https://github.com/mtdowling"
12
+ }
13
+ ],
14
+ "require": {
15
+ "php": ">=5.5.0"
16
+ },
17
+ "require-dev": {
18
+ "phpunit/phpunit": "~4.0"
19
+ },
20
+ "autoload": {
21
+ "psr-4": {
22
+ "GuzzleHttp\\Promise\\": "src/"
23
+ },
24
+ "files": ["src/functions_include.php"]
25
+ },
26
+ "extra": {
27
+ "branch-alias": {
28
+ "dev-master": "1.0-dev"
29
+ }
30
+ }
31
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./tests/bootstrap.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ <exclude>
13
+ <directory suffix="Interface.php">src/</directory>
14
+ </exclude>
15
+ </whitelist>
16
+ </filter>
17
+ </phpunit>
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/AggregateException.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception thrown when too many errors occur in the some() or any() methods.
6
+ */
7
+ class AggregateException extends RejectionException
8
+ {
9
+ public function __construct($msg, array $reasons)
10
+ {
11
+ parent::__construct(
12
+ $reasons,
13
+ sprintf('%s; %d rejected promises', $msg, count($reasons))
14
+ );
15
+ }
16
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/CancellationException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception that is set as the reason for a promise that has been cancelled.
6
+ */
7
+ class CancellationException extends RejectionException
8
+ {
9
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/EachPromise.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Represents a promise that iterates over many promises and invokes
6
+ * side-effect functions in the process.
7
+ */
8
+ class EachPromise implements PromisorInterface
9
+ {
10
+ private $pending = [];
11
+
12
+ /** @var \Iterator */
13
+ private $iterable;
14
+
15
+ /** @var callable|int */
16
+ private $concurrency;
17
+
18
+ /** @var callable */
19
+ private $onFulfilled;
20
+
21
+ /** @var callable */
22
+ private $onRejected;
23
+
24
+ /** @var Promise */
25
+ private $aggregate;
26
+
27
+ /** @var bool */
28
+ private $mutex;
29
+
30
+ /**
31
+ * Configuration hash can include the following key value pairs:
32
+ *
33
+ * - fulfilled: (callable) Invoked when a promise fulfills. The function
34
+ * is invoked with three arguments: the fulfillment value, the index
35
+ * position from the iterable list of the promise, and the aggregate
36
+ * promise that manages all of the promises. The aggregate promise may
37
+ * be resolved from within the callback to short-circuit the promise.
38
+ * - rejected: (callable) Invoked when a promise is rejected. The
39
+ * function is invoked with three arguments: the rejection reason, the
40
+ * index position from the iterable list of the promise, and the
41
+ * aggregate promise that manages all of the promises. The aggregate
42
+ * promise may be resolved from within the callback to short-circuit
43
+ * the promise.
44
+ * - concurrency: (integer) Pass this configuration option to limit the
45
+ * allowed number of outstanding concurrently executing promises,
46
+ * creating a capped pool of promises. There is no limit by default.
47
+ *
48
+ * @param mixed $iterable Promises or values to iterate.
49
+ * @param array $config Configuration options
50
+ */
51
+ public function __construct($iterable, array $config = [])
52
+ {
53
+ $this->iterable = iter_for($iterable);
54
+
55
+ if (isset($config['concurrency'])) {
56
+ $this->concurrency = $config['concurrency'];
57
+ }
58
+
59
+ if (isset($config['fulfilled'])) {
60
+ $this->onFulfilled = $config['fulfilled'];
61
+ }
62
+
63
+ if (isset($config['rejected'])) {
64
+ $this->onRejected = $config['rejected'];
65
+ }
66
+ }
67
+
68
+ public function promise()
69
+ {
70
+ if ($this->aggregate) {
71
+ return $this->aggregate;
72
+ }
73
+
74
+ try {
75
+ $this->createPromise();
76
+ $this->iterable->rewind();
77
+ $this->refillPending();
78
+ } catch (\Throwable $e) {
79
+ $this->aggregate->reject($e);
80
+ } catch (\Exception $e) {
81
+ $this->aggregate->reject($e);
82
+ }
83
+
84
+ return $this->aggregate;
85
+ }
86
+
87
+ private function createPromise()
88
+ {
89
+ $this->mutex = false;
90
+ $this->aggregate = new Promise(function () {
91
+ reset($this->pending);
92
+ if (empty($this->pending) && !$this->iterable->valid()) {
93
+ $this->aggregate->resolve(null);
94
+ return;
95
+ }
96
+
97
+ // Consume a potentially fluctuating list of promises while
98
+ // ensuring that indexes are maintained (precluding array_shift).
99
+ while ($promise = current($this->pending)) {
100
+ next($this->pending);
101
+ $promise->wait();
102
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
103
+ return;
104
+ }
105
+ }
106
+ });
107
+
108
+ // Clear the references when the promise is resolved.
109
+ $clearFn = function () {
110
+ $this->iterable = $this->concurrency = $this->pending = null;
111
+ $this->onFulfilled = $this->onRejected = null;
112
+ };
113
+
114
+ $this->aggregate->then($clearFn, $clearFn);
115
+ }
116
+
117
+ private function refillPending()
118
+ {
119
+ if (!$this->concurrency) {
120
+ // Add all pending promises.
121
+ while ($this->addPending() && $this->advanceIterator());
122
+ return;
123
+ }
124
+
125
+ // Add only up to N pending promises.
126
+ $concurrency = is_callable($this->concurrency)
127
+ ? call_user_func($this->concurrency, count($this->pending))
128
+ : $this->concurrency;
129
+ $concurrency = max($concurrency - count($this->pending), 0);
130
+ // Concurrency may be set to 0 to disallow new promises.
131
+ if (!$concurrency) {
132
+ return;
133
+ }
134
+ // Add the first pending promise.
135
+ $this->addPending();
136
+ // Note this is special handling for concurrency=1 so that we do
137
+ // not advance the iterator after adding the first promise. This
138
+ // helps work around issues with generators that might not have the
139
+ // next value to yield until promise callbacks are called.
140
+ while (--$concurrency
141
+ && $this->advanceIterator()
142
+ && $this->addPending());
143
+ }
144
+
145
+ private function addPending()
146
+ {
147
+ if (!$this->iterable || !$this->iterable->valid()) {
148
+ return false;
149
+ }
150
+
151
+ $promise = promise_for($this->iterable->current());
152
+ $idx = $this->iterable->key();
153
+
154
+ $this->pending[$idx] = $promise->then(
155
+ function ($value) use ($idx) {
156
+ if ($this->onFulfilled) {
157
+ call_user_func(
158
+ $this->onFulfilled, $value, $idx, $this->aggregate
159
+ );
160
+ }
161
+ $this->step($idx);
162
+ },
163
+ function ($reason) use ($idx) {
164
+ if ($this->onRejected) {
165
+ call_user_func(
166
+ $this->onRejected, $reason, $idx, $this->aggregate
167
+ );
168
+ }
169
+ $this->step($idx);
170
+ }
171
+ );
172
+
173
+ return true;
174
+ }
175
+
176
+ private function advanceIterator()
177
+ {
178
+ // Place a lock on the iterator so that we ensure to not recurse,
179
+ // preventing fatal generator errors.
180
+ if ($this->mutex) {
181
+ return false;
182
+ }
183
+
184
+ $this->mutex = true;
185
+
186
+ try {
187
+ $this->iterable->next();
188
+ $this->mutex = false;
189
+ return true;
190
+ } catch (\Throwable $e) {
191
+ $this->aggregate->reject($e);
192
+ $this->mutex = false;
193
+ return false;
194
+ } catch (\Exception $e) {
195
+ $this->aggregate->reject($e);
196
+ $this->mutex = false;
197
+ return false;
198
+ }
199
+ }
200
+
201
+ private function step($idx)
202
+ {
203
+ // If the promise was already resolved, then ignore this step.
204
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
205
+ return;
206
+ }
207
+
208
+ unset($this->pending[$idx]);
209
+
210
+ // Only refill pending promises if we are not locked, preventing the
211
+ // EachPromise to recursively invoke the provided iterator, which
212
+ // cause a fatal error: "Cannot resume an already running generator"
213
+ if ($this->advanceIterator() && !$this->checkIfFinished()) {
214
+ // Add more pending promises if possible.
215
+ $this->refillPending();
216
+ }
217
+ }
218
+
219
+ private function checkIfFinished()
220
+ {
221
+ if (!$this->pending && !$this->iterable->valid()) {
222
+ // Resolve the promise if there's nothing left to do.
223
+ $this->aggregate->resolve(null);
224
+ return true;
225
+ }
226
+
227
+ return false;
228
+ }
229
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/FulfilledPromise.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise that has been fulfilled.
6
+ *
7
+ * Thenning off of this promise will invoke the onFulfilled callback
8
+ * immediately and ignore other callbacks.
9
+ */
10
+ class FulfilledPromise implements PromiseInterface
11
+ {
12
+ private $value;
13
+
14
+ public function __construct($value)
15
+ {
16
+ if (method_exists($value, 'then')) {
17
+ throw new \InvalidArgumentException(
18
+ 'You cannot create a FulfilledPromise with a promise.');
19
+ }
20
+
21
+ $this->value = $value;
22
+ }
23
+
24
+ public function then(
25
+ callable $onFulfilled = null,
26
+ callable $onRejected = null
27
+ ) {
28
+ // Return itself if there is no onFulfilled function.
29
+ if (!$onFulfilled) {
30
+ return $this;
31
+ }
32
+
33
+ $queue = queue();
34
+ $p = new Promise([$queue, 'run']);
35
+ $value = $this->value;
36
+ $queue->add(static function () use ($p, $value, $onFulfilled) {
37
+ if ($p->getState() === self::PENDING) {
38
+ try {
39
+ $p->resolve($onFulfilled($value));
40
+ } catch (\Throwable $e) {
41
+ $p->reject($e);
42
+ } catch (\Exception $e) {
43
+ $p->reject($e);
44
+ }
45
+ }
46
+ });
47
+
48
+ return $p;
49
+ }
50
+
51
+ public function otherwise(callable $onRejected)
52
+ {
53
+ return $this->then(null, $onRejected);
54
+ }
55
+
56
+ public function wait($unwrap = true, $defaultDelivery = null)
57
+ {
58
+ return $unwrap ? $this->value : null;
59
+ }
60
+
61
+ public function getState()
62
+ {
63
+ return self::FULFILLED;
64
+ }
65
+
66
+ public function resolve($value)
67
+ {
68
+ if ($value !== $this->value) {
69
+ throw new \LogicException("Cannot resolve a fulfilled promise");
70
+ }
71
+ }
72
+
73
+ public function reject($reason)
74
+ {
75
+ throw new \LogicException("Cannot reject a fulfilled promise");
76
+ }
77
+
78
+ public function cancel()
79
+ {
80
+ // pass
81
+ }
82
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/Promise.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Promises/A+ implementation that avoids recursion when possible.
6
+ *
7
+ * @link https://promisesaplus.com/
8
+ */
9
+ class Promise implements PromiseInterface
10
+ {
11
+ private $state = self::PENDING;
12
+ private $result;
13
+ private $cancelFn;
14
+ private $waitFn;
15
+ private $waitList;
16
+ private $handlers = [];
17
+
18
+ /**
19
+ * @param callable $waitFn Fn that when invoked resolves the promise.
20
+ * @param callable $cancelFn Fn that when invoked cancels the promise.
21
+ */
22
+ public function __construct(
23
+ callable $waitFn = null,
24
+ callable $cancelFn = null
25
+ ) {
26
+ $this->waitFn = $waitFn;
27
+ $this->cancelFn = $cancelFn;
28
+ }
29
+
30
+ public function then(
31
+ callable $onFulfilled = null,
32
+ callable $onRejected = null
33
+ ) {
34
+ if ($this->state === self::PENDING) {
35
+ $p = new Promise(null, [$this, 'cancel']);
36
+ $this->handlers[] = [$p, $onFulfilled, $onRejected];
37
+ $p->waitList = $this->waitList;
38
+ $p->waitList[] = $this;
39
+ return $p;
40
+ }
41
+
42
+ // Return a fulfilled promise and immediately invoke any callbacks.
43
+ if ($this->state === self::FULFILLED) {
44
+ return $onFulfilled
45
+ ? promise_for($this->result)->then($onFulfilled)
46
+ : promise_for($this->result);
47
+ }
48
+
49
+ // It's either cancelled or rejected, so return a rejected promise
50
+ // and immediately invoke any callbacks.
51
+ $rejection = rejection_for($this->result);
52
+ return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
53
+ }
54
+
55
+ public function otherwise(callable $onRejected)
56
+ {
57
+ return $this->then(null, $onRejected);
58
+ }
59
+
60
+ public function wait($unwrap = true)
61
+ {
62
+ $this->waitIfPending();
63
+
64
+ $inner = $this->result instanceof PromiseInterface
65
+ ? $this->result->wait($unwrap)
66
+ : $this->result;
67
+
68
+ if ($unwrap) {
69
+ if ($this->result instanceof PromiseInterface
70
+ || $this->state === self::FULFILLED
71
+ ) {
72
+ return $inner;
73
+ } else {
74
+ // It's rejected so "unwrap" and throw an exception.
75
+ throw exception_for($inner);
76
+ }
77
+ }
78
+ }
79
+
80
+ public function getState()
81
+ {
82
+ return $this->state;
83
+ }
84
+
85
+ public function cancel()
86
+ {
87
+ if ($this->state !== self::PENDING) {
88
+ return;
89
+ }
90
+
91
+ $this->waitFn = $this->waitList = null;
92
+
93
+ if ($this->cancelFn) {
94
+ $fn = $this->cancelFn;
95
+ $this->cancelFn = null;
96
+ try {
97
+ $fn();
98
+ } catch (\Throwable $e) {
99
+ $this->reject($e);
100
+ } catch (\Exception $e) {
101
+ $this->reject($e);
102
+ }
103
+ }
104
+
105
+ // Reject the promise only if it wasn't rejected in a then callback.
106
+ if ($this->state === self::PENDING) {
107
+ $this->reject(new CancellationException('Promise has been cancelled'));
108
+ }
109
+ }
110
+
111
+ public function resolve($value)
112
+ {
113
+ $this->settle(self::FULFILLED, $value);
114
+ }
115
+
116
+ public function reject($reason)
117
+ {
118
+ $this->settle(self::REJECTED, $reason);
119
+ }
120
+
121
+ private function settle($state, $value)
122
+ {
123
+ if ($this->state !== self::PENDING) {
124
+ // Ignore calls with the same resolution.
125
+ if ($state === $this->state && $value === $this->result) {
126
+ return;
127
+ }
128
+ throw $this->state === $state
129
+ ? new \LogicException("The promise is already {$state}.")
130
+ : new \LogicException("Cannot change a {$this->state} promise to {$state}");
131
+ }
132
+
133
+ if ($value === $this) {
134
+ throw new \LogicException('Cannot fulfill or reject a promise with itself');
135
+ }
136
+
137
+ // Clear out the state of the promise but stash the handlers.
138
+ $this->state = $state;
139
+ $this->result = $value;
140
+ $handlers = $this->handlers;
141
+ $this->handlers = null;
142
+ $this->waitList = $this->waitFn = null;
143
+ $this->cancelFn = null;
144
+
145
+ if (!$handlers) {
146
+ return;
147
+ }
148
+
149
+ // If the value was not a settled promise or a thenable, then resolve
150
+ // it in the task queue using the correct ID.
151
+ if (!method_exists($value, 'then')) {
152
+ $id = $state === self::FULFILLED ? 1 : 2;
153
+ // It's a success, so resolve the handlers in the queue.
154
+ queue()->add(static function () use ($id, $value, $handlers) {
155
+ foreach ($handlers as $handler) {
156
+ self::callHandler($id, $value, $handler);
157
+ }
158
+ });
159
+ } elseif ($value instanceof Promise
160
+ && $value->getState() === self::PENDING
161
+ ) {
162
+ // We can just merge our handlers onto the next promise.
163
+ $value->handlers = array_merge($value->handlers, $handlers);
164
+ } else {
165
+ // Resolve the handlers when the forwarded promise is resolved.
166
+ $value->then(
167
+ static function ($value) use ($handlers) {
168
+ foreach ($handlers as $handler) {
169
+ self::callHandler(1, $value, $handler);
170
+ }
171
+ },
172
+ static function ($reason) use ($handlers) {
173
+ foreach ($handlers as $handler) {
174
+ self::callHandler(2, $reason, $handler);
175
+ }
176
+ }
177
+ );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Call a stack of handlers using a specific callback index and value.
183
+ *
184
+ * @param int $index 1 (resolve) or 2 (reject).
185
+ * @param mixed $value Value to pass to the callback.
186
+ * @param array $handler Array of handler data (promise and callbacks).
187
+ *
188
+ * @return array Returns the next group to resolve.
189
+ */
190
+ private static function callHandler($index, $value, array $handler)
191
+ {
192
+ /** @var PromiseInterface $promise */
193
+ $promise = $handler[0];
194
+
195
+ // The promise may have been cancelled or resolved before placing
196
+ // this thunk in the queue.
197
+ if ($promise->getState() !== self::PENDING) {
198
+ return;
199
+ }
200
+
201
+ try {
202
+ if (isset($handler[$index])) {
203
+ $promise->resolve($handler[$index]($value));
204
+ } elseif ($index === 1) {
205
+ // Forward resolution values as-is.
206
+ $promise->resolve($value);
207
+ } else {
208
+ // Forward rejections down the chain.
209
+ $promise->reject($value);
210
+ }
211
+ } catch (\Throwable $reason) {
212
+ $promise->reject($reason);
213
+ } catch (\Exception $reason) {
214
+ $promise->reject($reason);
215
+ }
216
+ }
217
+
218
+ private function waitIfPending()
219
+ {
220
+ if ($this->state !== self::PENDING) {
221
+ return;
222
+ } elseif ($this->waitFn) {
223
+ $this->invokeWaitFn();
224
+ } elseif ($this->waitList) {
225
+ $this->invokeWaitList();
226
+ } else {
227
+ // If there's not wait function, then reject the promise.
228
+ $this->reject('Cannot wait on a promise that has '
229
+ . 'no internal wait function. You must provide a wait '
230
+ . 'function when constructing the promise to be able to '
231
+ . 'wait on a promise.');
232
+ }
233
+
234
+ queue()->run();
235
+
236
+ if ($this->state === self::PENDING) {
237
+ $this->reject('Invoking the wait callback did not resolve the promise');
238
+ }
239
+ }
240
+
241
+ private function invokeWaitFn()
242
+ {
243
+ try {
244
+ $wfn = $this->waitFn;
245
+ $this->waitFn = null;
246
+ $wfn(true);
247
+ } catch (\Exception $reason) {
248
+ if ($this->state === self::PENDING) {
249
+ // The promise has not been resolved yet, so reject the promise
250
+ // with the exception.
251
+ $this->reject($reason);
252
+ } else {
253
+ // The promise was already resolved, so there's a problem in
254
+ // the application.
255
+ throw $reason;
256
+ }
257
+ }
258
+ }
259
+
260
+ private function invokeWaitList()
261
+ {
262
+ $waitList = $this->waitList;
263
+ $this->waitList = null;
264
+
265
+ foreach ($waitList as $result) {
266
+ $result->waitIfPending();
267
+ while ($result->result instanceof Promise) {
268
+ $result = $result->result;
269
+ $result->waitIfPending();
270
+ }
271
+ }
272
+ }
273
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/PromiseInterface.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise represents the eventual result of an asynchronous operation.
6
+ *
7
+ * The primary way of interacting with a promise is through its then method,
8
+ * which registers callbacks to receive either a promise’s eventual value or
9
+ * the reason why the promise cannot be fulfilled.
10
+ *
11
+ * @link https://promisesaplus.com/
12
+ */
13
+ interface PromiseInterface
14
+ {
15
+ const PENDING = 'pending';
16
+ const FULFILLED = 'fulfilled';
17
+ const REJECTED = 'rejected';
18
+
19
+ /**
20
+ * Appends fulfillment and rejection handlers to the promise, and returns
21
+ * a new promise resolving to the return value of the called handler.
22
+ *
23
+ * @param callable $onFulfilled Invoked when the promise fulfills.
24
+ * @param callable $onRejected Invoked when the promise is rejected.
25
+ *
26
+ * @return PromiseInterface
27
+ */
28
+ public function then(
29
+ callable $onFulfilled = null,
30
+ callable $onRejected = null
31
+ );
32
+
33
+ /**
34
+ * Appends a rejection handler callback to the promise, and returns a new
35
+ * promise resolving to the return value of the callback if it is called,
36
+ * or to its original fulfillment value if the promise is instead
37
+ * fulfilled.
38
+ *
39
+ * @param callable $onRejected Invoked when the promise is rejected.
40
+ *
41
+ * @return PromiseInterface
42
+ */
43
+ public function otherwise(callable $onRejected);
44
+
45
+ /**
46
+ * Get the state of the promise ("pending", "rejected", or "fulfilled").
47
+ *
48
+ * The three states can be checked against the constants defined on
49
+ * PromiseInterface: PENDING, FULFILLED, and REJECTED.
50
+ *
51
+ * @return string
52
+ */
53
+ public function getState();
54
+
55
+ /**
56
+ * Resolve the promise with the given value.
57
+ *
58
+ * @param mixed $value
59
+ * @throws \RuntimeException if the promise is already resolved.
60
+ */
61
+ public function resolve($value);
62
+
63
+ /**
64
+ * Reject the promise with the given reason.
65
+ *
66
+ * @param mixed $reason
67
+ * @throws \RuntimeException if the promise is already resolved.
68
+ */
69
+ public function reject($reason);
70
+
71
+ /**
72
+ * Cancels the promise if possible.
73
+ *
74
+ * @link https://github.com/promises-aplus/cancellation-spec/issues/7
75
+ */
76
+ public function cancel();
77
+
78
+ /**
79
+ * Waits until the promise completes if possible.
80
+ *
81
+ * Pass $unwrap as true to unwrap the result of the promise, either
82
+ * returning the resolved value or throwing the rejected exception.
83
+ *
84
+ * If the promise cannot be waited on, then the promise will be rejected.
85
+ *
86
+ * @param bool $unwrap
87
+ *
88
+ * @return mixed
89
+ * @throws \LogicException if the promise has no wait function or if the
90
+ * promise does not settle after waiting.
91
+ */
92
+ public function wait($unwrap = true);
93
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/PromisorInterface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Interface used with classes that return a promise.
6
+ */
7
+ interface PromisorInterface
8
+ {
9
+ /**
10
+ * Returns a promise.
11
+ *
12
+ * @return PromiseInterface
13
+ */
14
+ public function promise();
15
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/RejectedPromise.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise that has been rejected.
6
+ *
7
+ * Thenning off of this promise will invoke the onRejected callback
8
+ * immediately and ignore other callbacks.
9
+ */
10
+ class RejectedPromise implements PromiseInterface
11
+ {
12
+ private $reason;
13
+
14
+ public function __construct($reason)
15
+ {
16
+ if (method_exists($reason, 'then')) {
17
+ throw new \InvalidArgumentException(
18
+ 'You cannot create a RejectedPromise with a promise.');
19
+ }
20
+
21
+ $this->reason = $reason;
22
+ }
23
+
24
+ public function then(
25
+ callable $onFulfilled = null,
26
+ callable $onRejected = null
27
+ ) {
28
+ // If there's no onRejected callback then just return self.
29
+ if (!$onRejected) {
30
+ return $this;
31
+ }
32
+
33
+ $queue = queue();
34
+ $reason = $this->reason;
35
+ $p = new Promise([$queue, 'run']);
36
+ $queue->add(static function () use ($p, $reason, $onRejected) {
37
+ if ($p->getState() === self::PENDING) {
38
+ try {
39
+ // Return a resolved promise if onRejected does not throw.
40
+ $p->resolve($onRejected($reason));
41
+ } catch (\Throwable $e) {
42
+ // onRejected threw, so return a rejected promise.
43
+ $p->reject($e);
44
+ } catch (\Exception $e) {
45
+ // onRejected threw, so return a rejected promise.
46
+ $p->reject($e);
47
+ }
48
+ }
49
+ });
50
+
51
+ return $p;
52
+ }
53
+
54
+ public function otherwise(callable $onRejected)
55
+ {
56
+ return $this->then(null, $onRejected);
57
+ }
58
+
59
+ public function wait($unwrap = true, $defaultDelivery = null)
60
+ {
61
+ if ($unwrap) {
62
+ throw exception_for($this->reason);
63
+ }
64
+ }
65
+
66
+ public function getState()
67
+ {
68
+ return self::REJECTED;
69
+ }
70
+
71
+ public function resolve($value)
72
+ {
73
+ throw new \LogicException("Cannot resolve a rejected promise");
74
+ }
75
+
76
+ public function reject($reason)
77
+ {
78
+ if ($reason !== $this->reason) {
79
+ throw new \LogicException("Cannot reject a rejected promise");
80
+ }
81
+ }
82
+
83
+ public function cancel()
84
+ {
85
+ // pass
86
+ }
87
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/RejectionException.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A special exception that is thrown when waiting on a rejected promise.
6
+ *
7
+ * The reason value is available via the getReason() method.
8
+ */
9
+ class RejectionException extends \RuntimeException
10
+ {
11
+ /** @var mixed Rejection reason. */
12
+ private $reason;
13
+
14
+ /**
15
+ * @param mixed $reason Rejection reason.
16
+ * @param string $description Optional description
17
+ */
18
+ public function __construct($reason, $description = null)
19
+ {
20
+ $this->reason = $reason;
21
+
22
+ $message = 'The promise was rejected';
23
+
24
+ if ($description) {
25
+ $message .= ' with reason: ' . $description;
26
+ } elseif (is_string($reason)
27
+ || (is_object($reason) && method_exists($reason, '__toString'))
28
+ ) {
29
+ $message .= ' with reason: ' . $this->reason;
30
+ } elseif ($reason instanceof \JsonSerializable) {
31
+ $message .= ' with reason: '
32
+ . json_encode($this->reason, JSON_PRETTY_PRINT);
33
+ }
34
+
35
+ parent::__construct($message);
36
+ }
37
+
38
+ /**
39
+ * Returns the rejection reason.
40
+ *
41
+ * @return mixed
42
+ */
43
+ public function getReason()
44
+ {
45
+ return $this->reason;
46
+ }
47
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/TaskQueue.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A task queue that executes tasks in a FIFO order.
6
+ *
7
+ * This task queue class is used to settle promises asynchronously and
8
+ * maintains a constant stack size. You can use the task queue asynchronously
9
+ * by calling the `run()` function of the global task queue in an event loop.
10
+ *
11
+ * GuzzleHttp\Promise\queue()->run();
12
+ */
13
+ class TaskQueue
14
+ {
15
+ private $enableShutdown = true;
16
+ private $queue = [];
17
+
18
+ public function __construct($withShutdown = true)
19
+ {
20
+ if ($withShutdown) {
21
+ register_shutdown_function(function () {
22
+ if ($this->enableShutdown) {
23
+ // Only run the tasks if an E_ERROR didn't occur.
24
+ $err = error_get_last();
25
+ if (!$err || ($err['type'] ^ E_ERROR)) {
26
+ $this->run();
27
+ }
28
+ }
29
+ });
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Returns true if the queue is empty.
35
+ *
36
+ * @return bool
37
+ */
38
+ public function isEmpty()
39
+ {
40
+ return !$this->queue;
41
+ }
42
+
43
+ /**
44
+ * Adds a task to the queue that will be executed the next time run is
45
+ * called.
46
+ *
47
+ * @param callable $task
48
+ */
49
+ public function add(callable $task)
50
+ {
51
+ $this->queue[] = $task;
52
+ }
53
+
54
+ /**
55
+ * Execute all of the pending task in the queue.
56
+ */
57
+ public function run()
58
+ {
59
+ /** @var callable $task */
60
+ while ($task = array_shift($this->queue)) {
61
+ $task();
62
+ }
63
+ }
64
+
65
+ /**
66
+ * The task queue will be run and exhausted by default when the process
67
+ * exits IFF the exit is not the result of a PHP E_ERROR error.
68
+ *
69
+ * You can disable running the automatic shutdown of the queue by calling
70
+ * this function. If you disable the task queue shutdown process, then you
71
+ * MUST either run the task queue (as a result of running your event loop
72
+ * or manually using the run() method) or wait on each outstanding promise.
73
+ *
74
+ * Note: This shutdown will occur before any destructors are triggered.
75
+ */
76
+ public function disableShutdown()
77
+ {
78
+ $this->enableShutdown = false;
79
+ }
80
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/functions.php ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Get the global task queue used for promise resolution.
6
+ *
7
+ * This task queue MUST be run in an event loop in order for promises to be
8
+ * settled asynchronously. It will be automatically run when synchronously
9
+ * waiting on a promise.
10
+ *
11
+ * <code>
12
+ * while ($eventLoop->isRunning()) {
13
+ * GuzzleHttp\Promise\queue()->run();
14
+ * }
15
+ * </code>
16
+ *
17
+ * @return TaskQueue
18
+ */
19
+ function queue()
20
+ {
21
+ static $queue;
22
+
23
+ if (!$queue) {
24
+ $queue = new TaskQueue();
25
+ }
26
+
27
+ return $queue;
28
+ }
29
+
30
+ /**
31
+ * Adds a function to run in the task queue when it is next `run()` and returns
32
+ * a promise that is fulfilled or rejected with the result.
33
+ *
34
+ * @param callable $task Task function to run.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ function task(callable $task)
39
+ {
40
+ $queue = queue();
41
+ $promise = new Promise([$queue, 'run']);
42
+ $queue->add(function () use ($task, $promise) {
43
+ try {
44
+ $promise->resolve($task());
45
+ } catch (\Throwable $e) {
46
+ $promise->reject($e);
47
+ } catch (\Exception $e) {
48
+ $promise->reject($e);
49
+ }
50
+ });
51
+
52
+ return $promise;
53
+ }
54
+
55
+ /**
56
+ * Creates a promise for a value if the value is not a promise.
57
+ *
58
+ * @param mixed $value Promise or value.
59
+ *
60
+ * @return PromiseInterface
61
+ */
62
+ function promise_for($value)
63
+ {
64
+ if ($value instanceof PromiseInterface) {
65
+ return $value;
66
+ }
67
+
68
+ // Return a Guzzle promise that shadows the given promise.
69
+ if (method_exists($value, 'then')) {
70
+ $wfn = method_exists($value, 'wait') ? [$value, 'wait'] : null;
71
+ $cfn = method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
72
+ $promise = new Promise($wfn, $cfn);
73
+ $value->then([$promise, 'resolve'], [$promise, 'reject']);
74
+ return $promise;
75
+ }
76
+
77
+ return new FulfilledPromise($value);
78
+ }
79
+
80
+ /**
81
+ * Creates a rejected promise for a reason if the reason is not a promise. If
82
+ * the provided reason is a promise, then it is returned as-is.
83
+ *
84
+ * @param mixed $reason Promise or reason.
85
+ *
86
+ * @return PromiseInterface
87
+ */
88
+ function rejection_for($reason)
89
+ {
90
+ if ($reason instanceof PromiseInterface) {
91
+ return $reason;
92
+ }
93
+
94
+ return new RejectedPromise($reason);
95
+ }
96
+
97
+ /**
98
+ * Create an exception for a rejected promise value.
99
+ *
100
+ * @param mixed $reason
101
+ *
102
+ * @return \Exception|\Throwable
103
+ */
104
+ function exception_for($reason)
105
+ {
106
+ return $reason instanceof \Exception || $reason instanceof \Throwable
107
+ ? $reason
108
+ : new RejectionException($reason);
109
+ }
110
+
111
+ /**
112
+ * Returns an iterator for the given value.
113
+ *
114
+ * @param mixed $value
115
+ *
116
+ * @return \Iterator
117
+ */
118
+ function iter_for($value)
119
+ {
120
+ if ($value instanceof \Iterator) {
121
+ return $value;
122
+ } elseif (is_array($value)) {
123
+ return new \ArrayIterator($value);
124
+ } else {
125
+ return new \ArrayIterator([$value]);
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Synchronously waits on a promise to resolve and returns an inspection state
131
+ * array.
132
+ *
133
+ * Returns a state associative array containing a "state" key mapping to a
134
+ * valid promise state. If the state of the promise is "fulfilled", the array
135
+ * will contain a "value" key mapping to the fulfilled value of the promise. If
136
+ * the promise is rejected, the array will contain a "reason" key mapping to
137
+ * the rejection reason of the promise.
138
+ *
139
+ * @param PromiseInterface $promise Promise or value.
140
+ *
141
+ * @return array
142
+ */
143
+ function inspect(PromiseInterface $promise)
144
+ {
145
+ try {
146
+ return [
147
+ 'state' => PromiseInterface::FULFILLED,
148
+ 'value' => $promise->wait()
149
+ ];
150
+ } catch (RejectionException $e) {
151
+ return ['state' => PromiseInterface::REJECTED, 'reason' => $e->getReason()];
152
+ } catch (\Throwable $e) {
153
+ return ['state' => PromiseInterface::REJECTED, 'reason' => $e];
154
+ } catch (\Exception $e) {
155
+ return ['state' => PromiseInterface::REJECTED, 'reason' => $e];
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Waits on all of the provided promises, but does not unwrap rejected promises
161
+ * as thrown exception.
162
+ *
163
+ * Returns an array of inspection state arrays.
164
+ *
165
+ * @param PromiseInterface[] $promises Traversable of promises to wait upon.
166
+ *
167
+ * @return array
168
+ * @see GuzzleHttp\Promise\inspect for the inspection state array format.
169
+ */
170
+ function inspect_all($promises)
171
+ {
172
+ $results = [];
173
+ foreach ($promises as $key => $promise) {
174
+ $results[$key] = inspect($promise);
175
+ }
176
+
177
+ return $results;
178
+ }
179
+
180
+ /**
181
+ * Waits on all of the provided promises and returns the fulfilled values.
182
+ *
183
+ * Returns an array that contains the value of each promise (in the same order
184
+ * the promises were provided). An exception is thrown if any of the promises
185
+ * are rejected.
186
+ *
187
+ * @param mixed $promises Iterable of PromiseInterface objects to wait on.
188
+ *
189
+ * @return array
190
+ * @throws \Exception on error
191
+ * @throws \Throwable on error in PHP >=7
192
+ */
193
+ function unwrap($promises)
194
+ {
195
+ $results = [];
196
+ foreach ($promises as $key => $promise) {
197
+ $results[$key] = $promise->wait();
198
+ }
199
+
200
+ return $results;
201
+ }
202
+
203
+ /**
204
+ * Given an array of promises, return a promise that is fulfilled when all the
205
+ * items in the array are fulfilled.
206
+ *
207
+ * The promise's fulfillment value is an array with fulfillment values at
208
+ * respective positions to the original array. If any promise in the array
209
+ * rejects, the returned promise is rejected with the rejection reason.
210
+ *
211
+ * @param mixed $promises Promises or values.
212
+ *
213
+ * @return Promise
214
+ */
215
+ function all($promises)
216
+ {
217
+ $results = [];
218
+ return each(
219
+ $promises,
220
+ function ($value, $idx) use (&$results) {
221
+ $results[$idx] = $value;
222
+ },
223
+ function ($reason, $idx, Promise $aggregate) {
224
+ $aggregate->reject($reason);
225
+ }
226
+ )->then(function () use (&$results) {
227
+ ksort($results);
228
+ return $results;
229
+ });
230
+ }
231
+
232
+ /**
233
+ * Initiate a competitive race between multiple promises or values (values will
234
+ * become immediately fulfilled promises).
235
+ *
236
+ * When count amount of promises have been fulfilled, the returned promise is
237
+ * fulfilled with an array that contains the fulfillment values of the winners
238
+ * in order of resolution.
239
+ *
240
+ * This prommise is rejected with a {@see GuzzleHttp\Promise\AggregateException}
241
+ * if the number of fulfilled promises is less than the desired $count.
242
+ *
243
+ * @param int $count Total number of promises.
244
+ * @param mixed $promises Promises or values.
245
+ *
246
+ * @return Promise
247
+ */
248
+ function some($count, $promises)
249
+ {
250
+ $results = [];
251
+ $rejections = [];
252
+
253
+ return each(
254
+ $promises,
255
+ function ($value, $idx, PromiseInterface $p) use (&$results, $count) {
256
+ if ($p->getState() !== PromiseInterface::PENDING) {
257
+ return;
258
+ }
259
+ $results[$idx] = $value;
260
+ if (count($results) >= $count) {
261
+ $p->resolve(null);
262
+ }
263
+ },
264
+ function ($reason) use (&$rejections) {
265
+ $rejections[] = $reason;
266
+ }
267
+ )->then(
268
+ function () use (&$results, &$rejections, $count) {
269
+ if (count($results) !== $count) {
270
+ throw new AggregateException(
271
+ 'Not enough promises to fulfill count',
272
+ $rejections
273
+ );
274
+ }
275
+ ksort($results);
276
+ return array_values($results);
277
+ }
278
+ );
279
+ }
280
+
281
+ /**
282
+ * Like some(), with 1 as count. However, if the promise fulfills, the
283
+ * fulfillment value is not an array of 1 but the value directly.
284
+ *
285
+ * @param mixed $promises Promises or values.
286
+ *
287
+ * @return PromiseInterface
288
+ */
289
+ function any($promises)
290
+ {
291
+ return some(1, $promises)->then(function ($values) { return $values[0]; });
292
+ }
293
+
294
+ /**
295
+ * Returns a promise that is fulfilled when all of the provided promises have
296
+ * been fulfilled or rejected.
297
+ *
298
+ * The returned promise is fulfilled with an array of inspection state arrays.
299
+ *
300
+ * @param mixed $promises Promises or values.
301
+ *
302
+ * @return Promise
303
+ * @see GuzzleHttp\Promise\inspect for the inspection state array format.
304
+ */
305
+ function settle($promises)
306
+ {
307
+ $results = [];
308
+
309
+ return each(
310
+ $promises,
311
+ function ($value, $idx) use (&$results) {
312
+ $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value];
313
+ },
314
+ function ($reason, $idx) use (&$results) {
315
+ $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason];
316
+ }
317
+ )->then(function () use (&$results) {
318
+ ksort($results);
319
+ return $results;
320
+ });
321
+ }
322
+
323
+ /**
324
+ * Given an iterator that yields promises or values, returns a promise that is
325
+ * fulfilled with a null value when the iterator has been consumed or the
326
+ * aggregate promise has been fulfilled or rejected.
327
+ *
328
+ * $onFulfilled is a function that accepts the fulfilled value, iterator
329
+ * index, and the aggregate promise. The callback can invoke any necessary side
330
+ * effects and choose to resolve or reject the aggregate promise if needed.
331
+ *
332
+ * $onRejected is a function that accepts the rejection reason, iterator
333
+ * index, and the aggregate promise. The callback can invoke any necessary side
334
+ * effects and choose to resolve or reject the aggregate promise if needed.
335
+ *
336
+ * @param mixed $iterable Iterator or array to iterate over.
337
+ * @param callable $onFulfilled
338
+ * @param callable $onRejected
339
+ *
340
+ * @return Promise
341
+ */
342
+ function each(
343
+ $iterable,
344
+ callable $onFulfilled = null,
345
+ callable $onRejected = null
346
+ ) {
347
+ return (new EachPromise($iterable, [
348
+ 'fulfilled' => $onFulfilled,
349
+ 'rejected' => $onRejected
350
+ ]))->promise();
351
+ }
352
+
353
+ /**
354
+ * Like each, but only allows a certain number of outstanding promises at any
355
+ * given time.
356
+ *
357
+ * $concurrency may be an integer or a function that accepts the number of
358
+ * pending promises and returns a numeric concurrency limit value to allow for
359
+ * dynamic a concurrency size.
360
+ *
361
+ * @param mixed $iterable
362
+ * @param int|callable $concurrency
363
+ * @param callable $onFulfilled
364
+ * @param callable $onRejected
365
+ *
366
+ * @return mixed
367
+ */
368
+ function each_limit(
369
+ $iterable,
370
+ $concurrency,
371
+ callable $onFulfilled = null,
372
+ callable $onRejected = null
373
+ ) {
374
+ return (new EachPromise($iterable, [
375
+ 'fulfilled' => $onFulfilled,
376
+ 'rejected' => $onRejected,
377
+ 'concurrency' => $concurrency
378
+ ]))->promise();
379
+ }
380
+
381
+ /**
382
+ * Like each_limit, but ensures that no promise in the given $iterable argument
383
+ * is rejected. If any promise is rejected, then the aggregate promise is
384
+ * rejected with the encountered rejection.
385
+ *
386
+ * @param mixed $iterable
387
+ * @param int|callable $concurrency
388
+ * @param callable $onFulfilled
389
+ *
390
+ * @return mixed
391
+ */
392
+ function each_limit_all(
393
+ $iterable,
394
+ $concurrency,
395
+ callable $onFulfilled = null
396
+ ) {
397
+ return each_limit(
398
+ $iterable,
399
+ $concurrency,
400
+ $onFulfilled,
401
+ function ($reason, $idx, PromiseInterface $aggregate) {
402
+ $aggregate->reject($reason);
403
+ }
404
+ );
405
+ }
406
+
407
+ /**
408
+ * Returns true if a promise is fulfilled.
409
+ *
410
+ * @param PromiseInterface $promise
411
+ *
412
+ * @return bool
413
+ */
414
+ function is_fulfilled(PromiseInterface $promise)
415
+ {
416
+ return $promise->getState() === PromiseInterface::FULFILLED;
417
+ }
418
+
419
+ /**
420
+ * Returns true if a promise is rejected.
421
+ *
422
+ * @param PromiseInterface $promise
423
+ *
424
+ * @return bool
425
+ */
426
+ function is_rejected(PromiseInterface $promise)
427
+ {
428
+ return $promise->getState() === PromiseInterface::REJECTED;
429
+ }
430
+
431
+ /**
432
+ * Returns true if a promise is fulfilled or rejected.
433
+ *
434
+ * @param PromiseInterface $promise
435
+ *
436
+ * @return bool
437
+ */
438
+ function is_settled(PromiseInterface $promise)
439
+ {
440
+ return $promise->getState() !== PromiseInterface::PENDING;
441
+ }
442
+
443
+ /**
444
+ * Creates a promise that is resolved using a generator that yields values or
445
+ * promises (somewhat similar to C#'s async keyword).
446
+ *
447
+ * When called, the coroutine function will start an instance of the generator
448
+ * and returns a promise that is fulfilled with its final yielded value.
449
+ *
450
+ * Control is returned back to the generator when the yielded promise settles.
451
+ * This can lead to less verbose code when doing lots of sequential async calls
452
+ * with minimal processing in between.
453
+ *
454
+ * use GuzzleHttp\Promise;
455
+ *
456
+ * function createPromise($value) {
457
+ * return new Promise\FulfilledPromise($value);
458
+ * }
459
+ *
460
+ * $promise = Promise\coroutine(function () {
461
+ * $value = (yield createPromise('a'));
462
+ * try {
463
+ * $value = (yield createPromise($value . 'b'));
464
+ * } catch (\Exception $e) {
465
+ * // The promise was rejected.
466
+ * }
467
+ * yield $value . 'c';
468
+ * });
469
+ *
470
+ * // Outputs "abc"
471
+ * $promise->then(function ($v) { echo $v; });
472
+ *
473
+ * @param callable $generatorFn Generator function to wrap into a promise.
474
+ *
475
+ * @return Promise
476
+ * @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
477
+ */
478
+ function coroutine(callable $generatorFn)
479
+ {
480
+ $generator = $generatorFn();
481
+ return __next_coroutine($generator->current(), $generator)->then();
482
+ }
483
+
484
+ /** @internal */
485
+ function __next_coroutine($yielded, \Generator $generator)
486
+ {
487
+ return promise_for($yielded)->then(
488
+ function ($value) use ($generator) {
489
+ $nextYield = $generator->send($value);
490
+ return $generator->valid()
491
+ ? __next_coroutine($nextYield, $generator)
492
+ : $value;
493
+ },
494
+ function ($reason) use ($generator) {
495
+ $nextYield = $generator->throw(exception_for($reason));
496
+ // The throw was caught, so keep iterating on the coroutine
497
+ return __next_coroutine($nextYield, $generator);
498
+ }
499
+ );
500
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\Promise\promise_for')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/AggregateExceptionTest.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\AggregateException;
5
+
6
+ class AggregateExceptionTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testHasReason()
9
+ {
10
+ $e = new AggregateException('foo', ['baz', 'bar']);
11
+ $this->assertContains('foo', $e->getMessage());
12
+ $this->assertEquals(['baz', 'bar'], $e->getReason());
13
+ }
14
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/EachPromiseTest.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\RejectedPromise;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\PromiseInterface;
8
+ use GuzzleHttp\Promise\EachPromise;
9
+ use GuzzleHttp\Promise as P;
10
+
11
+ /**
12
+ * @covers GuzzleHttp\Promise\EachPromise
13
+ */
14
+ class EachPromiseTest extends \PHPUnit_Framework_TestCase
15
+ {
16
+ public function testReturnsSameInstance()
17
+ {
18
+ $each = new EachPromise([], ['concurrency' => 100]);
19
+ $this->assertSame($each->promise(), $each->promise());
20
+ }
21
+
22
+ public function testInvokesAllPromises()
23
+ {
24
+ $promises = [new Promise(), new Promise(), new Promise()];
25
+ $called = [];
26
+ $each = new EachPromise($promises, [
27
+ 'fulfilled' => function ($value) use (&$called) {
28
+ $called[] = $value;
29
+ }
30
+ ]);
31
+ $p = $each->promise();
32
+ $promises[0]->resolve('a');
33
+ $promises[1]->resolve('c');
34
+ $promises[2]->resolve('b');
35
+ P\queue()->run();
36
+ $this->assertEquals(['a', 'c', 'b'], $called);
37
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
38
+ }
39
+
40
+ public function testIsWaitable()
41
+ {
42
+ $a = $this->createSelfResolvingPromise('a');
43
+ $b = $this->createSelfResolvingPromise('b');
44
+ $called = [];
45
+ $each = new EachPromise([$a, $b], [
46
+ 'fulfilled' => function ($value) use (&$called) { $called[] = $value; }
47
+ ]);
48
+ $p = $each->promise();
49
+ $this->assertNull($p->wait());
50
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
51
+ $this->assertEquals(['a', 'b'], $called);
52
+ }
53
+
54
+ public function testCanResolveBeforeConsumingAll()
55
+ {
56
+ $called = 0;
57
+ $a = $this->createSelfResolvingPromise('a');
58
+ $b = new Promise(function () { $this->fail(); });
59
+ $each = new EachPromise([$a, $b], [
60
+ 'fulfilled' => function ($value, $idx, Promise $aggregate) use (&$called) {
61
+ $this->assertSame($idx, 0);
62
+ $this->assertEquals('a', $value);
63
+ $aggregate->resolve(null);
64
+ $called++;
65
+ },
66
+ 'rejected' => function (\Exception $reason) {
67
+ $this->fail($reason->getMessage());
68
+ }
69
+ ]);
70
+ $p = $each->promise();
71
+ $p->wait();
72
+ $this->assertNull($p->wait());
73
+ $this->assertEquals(1, $called);
74
+ $this->assertEquals(PromiseInterface::FULFILLED, $a->getState());
75
+ $this->assertEquals(PromiseInterface::PENDING, $b->getState());
76
+ // Resolving $b has no effect on the aggregate promise.
77
+ $b->resolve('foo');
78
+ $this->assertEquals(1, $called);
79
+ }
80
+
81
+ public function testLimitsPendingPromises()
82
+ {
83
+ $pending = [new Promise(), new Promise(), new Promise(), new Promise()];
84
+ $promises = new \ArrayIterator($pending);
85
+ $each = new EachPromise($promises, ['concurrency' => 2]);
86
+ $p = $each->promise();
87
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
88
+ $pending[0]->resolve('a');
89
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
90
+ $this->assertTrue($promises->valid());
91
+ $pending[1]->resolve('b');
92
+ P\queue()->run();
93
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
94
+ $this->assertTrue($promises->valid());
95
+ $promises[2]->resolve('c');
96
+ P\queue()->run();
97
+ $this->assertCount(1, $this->readAttribute($each, 'pending'));
98
+ $this->assertEquals(PromiseInterface::PENDING, $p->getState());
99
+ $promises[3]->resolve('d');
100
+ P\queue()->run();
101
+ $this->assertNull($this->readAttribute($each, 'pending'));
102
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
103
+ $this->assertFalse($promises->valid());
104
+ }
105
+
106
+ public function testDynamicallyLimitsPendingPromises()
107
+ {
108
+ $calls = [];
109
+ $pendingFn = function ($count) use (&$calls) {
110
+ $calls[] = $count;
111
+ return 2;
112
+ };
113
+ $pending = [new Promise(), new Promise(), new Promise(), new Promise()];
114
+ $promises = new \ArrayIterator($pending);
115
+ $each = new EachPromise($promises, ['concurrency' => $pendingFn]);
116
+ $p = $each->promise();
117
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
118
+ $pending[0]->resolve('a');
119
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
120
+ $this->assertTrue($promises->valid());
121
+ $pending[1]->resolve('b');
122
+ $this->assertCount(2, $this->readAttribute($each, 'pending'));
123
+ P\queue()->run();
124
+ $this->assertTrue($promises->valid());
125
+ $promises[2]->resolve('c');
126
+ P\queue()->run();
127
+ $this->assertCount(1, $this->readAttribute($each, 'pending'));
128
+ $this->assertEquals(PromiseInterface::PENDING, $p->getState());
129
+ $promises[3]->resolve('d');
130
+ P\queue()->run();
131
+ $this->assertNull($this->readAttribute($each, 'pending'));
132
+ $this->assertEquals(PromiseInterface::FULFILLED, $p->getState());
133
+ $this->assertEquals([0, 1, 1, 1], $calls);
134
+ $this->assertFalse($promises->valid());
135
+ }
136
+
137
+ public function testClearsReferencesWhenResolved()
138
+ {
139
+ $called = false;
140
+ $a = new Promise(function () use (&$a, &$called) {
141
+ $a->resolve('a');
142
+ $called = true;
143
+ });
144
+ $each = new EachPromise([$a], [
145
+ 'concurrency' => function () { return 1; },
146
+ 'fulfilled' => function () {},
147
+ 'rejected' => function () {}
148
+ ]);
149
+ $each->promise()->wait();
150
+ $this->assertNull($this->readAttribute($each, 'onFulfilled'));
151
+ $this->assertNull($this->readAttribute($each, 'onRejected'));
152
+ $this->assertNull($this->readAttribute($each, 'iterable'));
153
+ $this->assertNull($this->readAttribute($each, 'pending'));
154
+ $this->assertNull($this->readAttribute($each, 'concurrency'));
155
+ $this->assertTrue($called);
156
+ }
157
+
158
+ public function testCanBeCancelled()
159
+ {
160
+ $this->markTestIncomplete();
161
+ }
162
+
163
+ public function testFulfillsImmediatelyWhenGivenAnEmptyIterator()
164
+ {
165
+ $each = new EachPromise(new \ArrayIterator([]));
166
+ $result = $each->promise()->wait();
167
+ }
168
+
169
+ public function testDoesNotBlowStackWithFulfilledPromises()
170
+ {
171
+ $pending = [];
172
+ for ($i = 0; $i < 100; $i++) {
173
+ $pending[] = new FulfilledPromise($i);
174
+ }
175
+ $values = [];
176
+ $each = new EachPromise($pending, [
177
+ 'fulfilled' => function ($value) use (&$values) {
178
+ $values[] = $value;
179
+ }
180
+ ]);
181
+ $called = false;
182
+ $each->promise()->then(function () use (&$called) {
183
+ $called = true;
184
+ });
185
+ $this->assertFalse($called);
186
+ P\queue()->run();
187
+ $this->assertTrue($called);
188
+ $this->assertEquals(range(0, 99), $values);
189
+ }
190
+
191
+ public function testDoesNotBlowStackWithRejectedPromises()
192
+ {
193
+ $pending = [];
194
+ for ($i = 0; $i < 100; $i++) {
195
+ $pending[] = new RejectedPromise($i);
196
+ }
197
+ $values = [];
198
+ $each = new EachPromise($pending, [
199
+ 'rejected' => function ($value) use (&$values) {
200
+ $values[] = $value;
201
+ }
202
+ ]);
203
+ $called = false;
204
+ $each->promise()->then(
205
+ function () use (&$called) { $called = true; },
206
+ function () { $this->fail('Should not have rejected.'); }
207
+ );
208
+ $this->assertFalse($called);
209
+ P\queue()->run();
210
+ $this->assertTrue($called);
211
+ $this->assertEquals(range(0, 99), $values);
212
+ }
213
+
214
+ public function testReturnsPromiseForWhatever()
215
+ {
216
+ $called = [];
217
+ $arr = ['a', 'b'];
218
+ $each = new EachPromise($arr, [
219
+ 'fulfilled' => function ($v) use (&$called) { $called[] = $v; }
220
+ ]);
221
+ $p = $each->promise();
222
+ $this->assertNull($p->wait());
223
+ $this->assertEquals(['a', 'b'], $called);
224
+ }
225
+
226
+ public function testRejectsAggregateWhenNextThrows()
227
+ {
228
+ $iter = function () {
229
+ yield 'a';
230
+ throw new \Exception('Failure');
231
+ };
232
+ $each = new EachPromise($iter());
233
+ $p = $each->promise();
234
+ $e = null;
235
+ $received = null;
236
+ $p->then(null, function ($reason) use (&$e) { $e = $reason; });
237
+ P\queue()->run();
238
+ $this->assertInstanceOf('Exception', $e);
239
+ $this->assertEquals('Failure', $e->getMessage());
240
+ }
241
+
242
+ public function testDoesNotCallNextOnIteratorUntilNeededWhenWaiting()
243
+ {
244
+ $results = [];
245
+ $values = [10];
246
+ $remaining = 9;
247
+ $iter = function () use (&$values) {
248
+ while ($value = array_pop($values)) {
249
+ yield $value;
250
+ }
251
+ };
252
+ $each = new EachPromise($iter(), [
253
+ 'concurrency' => 1,
254
+ 'fulfilled' => function ($r) use (&$results, &$values, &$remaining) {
255
+ $results[] = $r;
256
+ if ($remaining > 0) {
257
+ $values[] = $remaining--;
258
+ }
259
+ }
260
+ ]);
261
+ $each->promise()->wait();
262
+ $this->assertEquals(range(10, 1), $results);
263
+ }
264
+
265
+ public function testDoesNotCallNextOnIteratorUntilNeededWhenAsync()
266
+ {
267
+ $firstPromise = new Promise();
268
+ $pending = [$firstPromise];
269
+ $values = [$firstPromise];
270
+ $results = [];
271
+ $remaining = 9;
272
+ $iter = function () use (&$values) {
273
+ while ($value = array_pop($values)) {
274
+ yield $value;
275
+ }
276
+ };
277
+ $each = new EachPromise($iter(), [
278
+ 'concurrency' => 1,
279
+ 'fulfilled' => function ($r) use (&$results, &$values, &$remaining, &$pending) {
280
+ $results[] = $r;
281
+ if ($remaining-- > 0) {
282
+ $pending[] = $values[] = new Promise();
283
+ }
284
+ }
285
+ ]);
286
+ $i = 0;
287
+ $each->promise();
288
+ while ($promise = array_pop($pending)) {
289
+ $promise->resolve($i++);
290
+ P\queue()->run();
291
+ }
292
+ $this->assertEquals(range(0, 9), $results);
293
+ }
294
+
295
+ private function createSelfResolvingPromise($value)
296
+ {
297
+ $p = new Promise(function () use (&$p, $value) {
298
+ $p->resolve($value);
299
+ });
300
+
301
+ return $p;
302
+ }
303
+
304
+ public function testMutexPreventsGeneratorRecursion()
305
+ {
306
+ $results = $promises = [];
307
+ for ($i = 0; $i < 20; $i++) {
308
+ $p = $this->createSelfResolvingPromise($i);
309
+ $pending[] = $p;
310
+ $promises[] = $p;
311
+ }
312
+
313
+ $iter = function () use (&$promises, &$pending) {
314
+ foreach ($promises as $promise) {
315
+ // Resolve a promises, which will trigger the then() function,
316
+ // which would cause the EachPromise to try to add more
317
+ // promises to the queue. Without a lock, this would trigger
318
+ // a "Cannot resume an already running generator" fatal error.
319
+ if ($p = array_pop($pending)) {
320
+ $p->wait();
321
+ }
322
+ yield $promise;
323
+ }
324
+ };
325
+
326
+ $each = new EachPromise($iter(), [
327
+ 'concurrency' => 5,
328
+ 'fulfilled' => function ($r) use (&$results, &$pending) {
329
+ $results[] = $r;
330
+ }
331
+ ]);
332
+
333
+ $each->promise()->wait();
334
+ $this->assertCount(20, $results);
335
+ }
336
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Promise;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Promise\FulfilledPromise
9
+ */
10
+ class FulfilledPromiseTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testReturnsValueWhenWaitedUpon()
13
+ {
14
+ $p = new FulfilledPromise('foo');
15
+ $this->assertEquals('fulfilled', $p->getState());
16
+ $this->assertEquals('foo', $p->wait(true));
17
+ }
18
+
19
+ public function testCannotCancel()
20
+ {
21
+ $p = new FulfilledPromise('foo');
22
+ $this->assertEquals('fulfilled', $p->getState());
23
+ $p->cancel();
24
+ $this->assertEquals('foo', $p->wait());
25
+ }
26
+
27
+ /**
28
+ * @expectedException \LogicException
29
+ * @exepctedExceptionMessage Cannot resolve a fulfilled promise
30
+ */
31
+ public function testCannotResolve()
32
+ {
33
+ $p = new FulfilledPromise('foo');
34
+ $p->resolve('bar');
35
+ }
36
+
37
+ /**
38
+ * @expectedException \LogicException
39
+ * @exepctedExceptionMessage Cannot reject a fulfilled promise
40
+ */
41
+ public function testCannotReject()
42
+ {
43
+ $p = new FulfilledPromise('foo');
44
+ $p->reject('bar');
45
+ }
46
+
47
+ public function testCanResolveWithSameValue()
48
+ {
49
+ $p = new FulfilledPromise('foo');
50
+ $p->resolve('foo');
51
+ }
52
+
53
+ /**
54
+ * @expectedException \InvalidArgumentException
55
+ */
56
+ public function testCannotResolveWithPromise()
57
+ {
58
+ new FulfilledPromise(new Promise());
59
+ }
60
+
61
+ public function testReturnsSelfWhenNoOnFulfilled()
62
+ {
63
+ $p = new FulfilledPromise('a');
64
+ $this->assertSame($p, $p->then());
65
+ }
66
+
67
+ public function testAsynchronouslyInvokesOnFulfilled()
68
+ {
69
+ $p = new FulfilledPromise('a');
70
+ $r = null;
71
+ $f = function ($d) use (&$r) { $r = $d; };
72
+ $p2 = $p->then($f);
73
+ $this->assertNotSame($p, $p2);
74
+ $this->assertNull($r);
75
+ \GuzzleHttp\Promise\queue()->run();
76
+ $this->assertEquals('a', $r);
77
+ }
78
+
79
+ public function testReturnsNewRejectedWhenOnFulfilledFails()
80
+ {
81
+ $p = new FulfilledPromise('a');
82
+ $f = function () { throw new \Exception('b'); };
83
+ $p2 = $p->then($f);
84
+ $this->assertNotSame($p, $p2);
85
+ try {
86
+ $p2->wait();
87
+ $this->fail();
88
+ } catch (\Exception $e) {
89
+ $this->assertEquals('b', $e->getMessage());
90
+ }
91
+ }
92
+
93
+ public function testOtherwiseIsSugarForRejections()
94
+ {
95
+ $c = null;
96
+ $p = new FulfilledPromise('foo');
97
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
98
+ $this->assertNull($c);
99
+ }
100
+
101
+ public function testDoesNotTryToFulfillTwiceDuringTrampoline()
102
+ {
103
+ $fp = new FulfilledPromise('a');
104
+ $t1 = $fp->then(function ($v) { return $v . ' b'; });
105
+ $t1->resolve('why!');
106
+ $this->assertEquals('why!', $t1->wait());
107
+ }
108
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\PromiseInterface;
6
+
7
+ class NotPromiseInstance extends Thennable implements PromiseInterface
8
+ {
9
+ private $nextPromise = null;
10
+
11
+ public function __construct()
12
+ {
13
+ $this->nextPromise = new Promise();
14
+ }
15
+
16
+ public function then(callable $res = null, callable $rej = null)
17
+ {
18
+ return $this->nextPromise->then($res, $rej);
19
+ }
20
+
21
+ public function otherwise(callable $onRejected)
22
+ {
23
+ return $this->then($onRejected);
24
+ }
25
+
26
+ public function resolve($value)
27
+ {
28
+ $this->nextPromise->resolve($value);
29
+ }
30
+
31
+ public function reject($reason)
32
+ {
33
+ $this->nextPromise->reject($reason);
34
+ }
35
+
36
+ public function wait($unwrap = true, $defaultResolution = null)
37
+ {
38
+
39
+ }
40
+
41
+ public function cancel()
42
+ {
43
+
44
+ }
45
+
46
+ public function getState()
47
+ {
48
+ return $this->nextPromise->getState();
49
+ }
50
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/PromiseTest.php ADDED
@@ -0,0 +1,591 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\CancellationException;
5
+ use GuzzleHttp\Promise as P;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+ use GuzzleHttp\Promise\RejectionException;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Promise\Promise
12
+ */
13
+ class PromiseTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /**
16
+ * @expectedException \LogicException
17
+ * @expectedExceptionMessage The promise is already fulfilled
18
+ */
19
+ public function testCannotResolveNonPendingPromise()
20
+ {
21
+ $p = new Promise();
22
+ $p->resolve('foo');
23
+ $p->resolve('bar');
24
+ $this->assertEquals('foo', $p->wait());
25
+ }
26
+
27
+ public function testCanResolveWithSameValue()
28
+ {
29
+ $p = new Promise();
30
+ $p->resolve('foo');
31
+ $p->resolve('foo');
32
+ }
33
+
34
+ /**
35
+ * @expectedException \LogicException
36
+ * @expectedExceptionMessage Cannot change a fulfilled promise to rejected
37
+ */
38
+ public function testCannotRejectNonPendingPromise()
39
+ {
40
+ $p = new Promise();
41
+ $p->resolve('foo');
42
+ $p->reject('bar');
43
+ $this->assertEquals('foo', $p->wait());
44
+ }
45
+
46
+ public function testCanRejectWithSameValue()
47
+ {
48
+ $p = new Promise();
49
+ $p->reject('foo');
50
+ $p->reject('foo');
51
+ }
52
+
53
+ /**
54
+ * @expectedException \LogicException
55
+ * @expectedExceptionMessage Cannot change a fulfilled promise to rejected
56
+ */
57
+ public function testCannotRejectResolveWithSameValue()
58
+ {
59
+ $p = new Promise();
60
+ $p->resolve('foo');
61
+ $p->reject('foo');
62
+ }
63
+
64
+ public function testInvokesWaitFunction()
65
+ {
66
+ $p = new Promise(function () use (&$p) { $p->resolve('10'); });
67
+ $this->assertEquals('10', $p->wait());
68
+ }
69
+
70
+ /**
71
+ * @expectedException \GuzzleHttp\Promise\RejectionException
72
+ */
73
+ public function testRejectsAndThrowsWhenWaitFailsToResolve()
74
+ {
75
+ $p = new Promise(function () {});
76
+ $p->wait();
77
+ }
78
+
79
+ /**
80
+ * @expectedException \GuzzleHttp\Promise\RejectionException
81
+ * @expectedExceptionMessage The promise was rejected with reason: foo
82
+ */
83
+ public function testThrowsWhenUnwrapIsRejectedWithNonException()
84
+ {
85
+ $p = new Promise(function () use (&$p) { $p->reject('foo'); });
86
+ $p->wait();
87
+ }
88
+
89
+ /**
90
+ * @expectedException \UnexpectedValueException
91
+ * @expectedExceptionMessage foo
92
+ */
93
+ public function testThrowsWhenUnwrapIsRejectedWithException()
94
+ {
95
+ $e = new \UnexpectedValueException('foo');
96
+ $p = new Promise(function () use (&$p, $e) { $p->reject($e); });
97
+ $p->wait();
98
+ }
99
+
100
+ public function testDoesNotUnwrapExceptionsWhenDisabled()
101
+ {
102
+ $p = new Promise(function () use (&$p) { $p->reject('foo'); });
103
+ $this->assertEquals('pending', $p->getState());
104
+ $p->wait(false);
105
+ $this->assertEquals('rejected', $p->getState());
106
+ }
107
+
108
+ public function testRejectsSelfWhenWaitThrows()
109
+ {
110
+ $e = new \UnexpectedValueException('foo');
111
+ $p = new Promise(function () use ($e) { throw $e; });
112
+ try {
113
+ $p->wait();
114
+ $this->fail();
115
+ } catch (\UnexpectedValueException $e) {
116
+ $this->assertEquals('rejected', $p->getState());
117
+ }
118
+ }
119
+
120
+ public function testWaitsOnNestedPromises()
121
+ {
122
+ $p = new Promise(function () use (&$p) { $p->resolve('_'); });
123
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('foo'); });
124
+ $p3 = $p->then(function () use ($p2) { return $p2; });
125
+ $this->assertSame('foo', $p3->wait());
126
+ }
127
+
128
+ /**
129
+ * @expectedException \GuzzleHttp\Promise\RejectionException
130
+ */
131
+ public function testThrowsWhenWaitingOnPromiseWithNoWaitFunction()
132
+ {
133
+ $p = new Promise();
134
+ $p->wait();
135
+ }
136
+
137
+ public function testThrowsWaitExceptionAfterPromiseIsResolved()
138
+ {
139
+ $p = new Promise(function () use (&$p) {
140
+ $p->reject('Foo!');
141
+ throw new \Exception('Bar?');
142
+ });
143
+
144
+ try {
145
+ $p->wait();
146
+ $this->fail();
147
+ } catch (\Exception $e) {
148
+ $this->assertEquals('Bar?', $e->getMessage());
149
+ }
150
+ }
151
+
152
+ public function testGetsActualWaitValueFromThen()
153
+ {
154
+ $p = new Promise(function () use (&$p) { $p->reject('Foo!'); });
155
+ $p2 = $p->then(null, function ($reason) {
156
+ return new RejectedPromise([$reason]);
157
+ });
158
+
159
+ try {
160
+ $p2->wait();
161
+ $this->fail('Should have thrown');
162
+ } catch (RejectionException $e) {
163
+ $this->assertEquals(['Foo!'], $e->getReason());
164
+ }
165
+ }
166
+
167
+ public function testWaitBehaviorIsBasedOnLastPromiseInChain()
168
+ {
169
+ $p3 = new Promise(function () use (&$p3) { $p3->resolve('Whoop'); });
170
+ $p2 = new Promise(function () use (&$p2, $p3) { $p2->reject($p3); });
171
+ $p = new Promise(function () use (&$p, $p2) { $p->reject($p2); });
172
+ $this->assertEquals('Whoop', $p->wait());
173
+ }
174
+
175
+ public function testWaitsOnAPromiseChainEvenWhenNotUnwrapped()
176
+ {
177
+ $p2 = new Promise(function () use (&$p2) {
178
+ $p2->reject('Fail');
179
+ });
180
+ $p = new Promise(function () use ($p2, &$p) {
181
+ $p->resolve($p2);
182
+ });
183
+ $p->wait(false);
184
+ $this->assertSame(Promise::REJECTED, $p2->getState());
185
+ }
186
+
187
+ public function testCannotCancelNonPending()
188
+ {
189
+ $p = new Promise();
190
+ $p->resolve('foo');
191
+ $p->cancel();
192
+ $this->assertEquals('fulfilled', $p->getState());
193
+ }
194
+
195
+ /**
196
+ * @expectedException \GuzzleHttp\Promise\CancellationException
197
+ */
198
+ public function testCancelsPromiseWhenNoCancelFunction()
199
+ {
200
+ $p = new Promise();
201
+ $p->cancel();
202
+ $this->assertEquals('rejected', $p->getState());
203
+ $p->wait();
204
+ }
205
+
206
+ public function testCancelsPromiseWithCancelFunction()
207
+ {
208
+ $called = false;
209
+ $p = new Promise(null, function () use (&$called) { $called = true; });
210
+ $p->cancel();
211
+ $this->assertEquals('rejected', $p->getState());
212
+ $this->assertTrue($called);
213
+ }
214
+
215
+ public function testCancelsUppermostPendingPromise()
216
+ {
217
+ $called = false;
218
+ $p1 = new Promise(null, function () use (&$called) { $called = true; });
219
+ $p2 = $p1->then(function () {});
220
+ $p3 = $p2->then(function () {});
221
+ $p4 = $p3->then(function () {});
222
+ $p3->cancel();
223
+ $this->assertEquals('rejected', $p1->getState());
224
+ $this->assertEquals('rejected', $p2->getState());
225
+ $this->assertEquals('rejected', $p3->getState());
226
+ $this->assertEquals('pending', $p4->getState());
227
+ $this->assertTrue($called);
228
+
229
+ try {
230
+ $p3->wait();
231
+ $this->fail();
232
+ } catch (CancellationException $e) {
233
+ $this->assertContains('cancelled', $e->getMessage());
234
+ }
235
+
236
+ try {
237
+ $p4->wait();
238
+ $this->fail();
239
+ } catch (CancellationException $e) {
240
+ $this->assertContains('cancelled', $e->getMessage());
241
+ }
242
+
243
+ $this->assertEquals('rejected', $p4->getState());
244
+ }
245
+
246
+ public function testCancelsChildPromises()
247
+ {
248
+ $called1 = $called2 = $called3 = false;
249
+ $p1 = new Promise(null, function () use (&$called1) { $called1 = true; });
250
+ $p2 = new Promise(null, function () use (&$called2) { $called2 = true; });
251
+ $p3 = new Promise(null, function () use (&$called3) { $called3 = true; });
252
+ $p4 = $p2->then(function () use ($p3) { return $p3; });
253
+ $p5 = $p4->then(function () { $this->fail(); });
254
+ $p4->cancel();
255
+ $this->assertEquals('pending', $p1->getState());
256
+ $this->assertEquals('rejected', $p2->getState());
257
+ $this->assertEquals('rejected', $p4->getState());
258
+ $this->assertEquals('pending', $p5->getState());
259
+ $this->assertFalse($called1);
260
+ $this->assertTrue($called2);
261
+ $this->assertFalse($called3);
262
+ }
263
+
264
+ public function testRejectsPromiseWhenCancelFails()
265
+ {
266
+ $called = false;
267
+ $p = new Promise(null, function () use (&$called) {
268
+ $called = true;
269
+ throw new \Exception('e');
270
+ });
271
+ $p->cancel();
272
+ $this->assertEquals('rejected', $p->getState());
273
+ $this->assertTrue($called);
274
+ try {
275
+ $p->wait();
276
+ $this->fail();
277
+ } catch (\Exception $e) {
278
+ $this->assertEquals('e', $e->getMessage());
279
+ }
280
+ }
281
+
282
+ public function testCreatesPromiseWhenFulfilledAfterThen()
283
+ {
284
+ $p = new Promise();
285
+ $carry = null;
286
+ $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; });
287
+ $this->assertNotSame($p, $p2);
288
+ $p->resolve('foo');
289
+ P\queue()->run();
290
+
291
+ $this->assertEquals('foo', $carry);
292
+ }
293
+
294
+ public function testCreatesPromiseWhenFulfilledBeforeThen()
295
+ {
296
+ $p = new Promise();
297
+ $p->resolve('foo');
298
+ $carry = null;
299
+ $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; });
300
+ $this->assertNotSame($p, $p2);
301
+ $this->assertNull($carry);
302
+ \GuzzleHttp\Promise\queue()->run();
303
+ $this->assertEquals('foo', $carry);
304
+ }
305
+
306
+ public function testCreatesPromiseWhenFulfilledWithNoCallback()
307
+ {
308
+ $p = new Promise();
309
+ $p->resolve('foo');
310
+ $p2 = $p->then();
311
+ $this->assertNotSame($p, $p2);
312
+ $this->assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p2);
313
+ }
314
+
315
+ public function testCreatesPromiseWhenRejectedAfterThen()
316
+ {
317
+ $p = new Promise();
318
+ $carry = null;
319
+ $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; });
320
+ $this->assertNotSame($p, $p2);
321
+ $p->reject('foo');
322
+ P\queue()->run();
323
+ $this->assertEquals('foo', $carry);
324
+ }
325
+
326
+ public function testCreatesPromiseWhenRejectedBeforeThen()
327
+ {
328
+ $p = new Promise();
329
+ $p->reject('foo');
330
+ $carry = null;
331
+ $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; });
332
+ $this->assertNotSame($p, $p2);
333
+ $this->assertNull($carry);
334
+ P\queue()->run();
335
+ $this->assertEquals('foo', $carry);
336
+ }
337
+
338
+ public function testCreatesPromiseWhenRejectedWithNoCallback()
339
+ {
340
+ $p = new Promise();
341
+ $p->reject('foo');
342
+ $p2 = $p->then();
343
+ $this->assertNotSame($p, $p2);
344
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p2);
345
+ }
346
+
347
+ public function testInvokesWaitFnsForThens()
348
+ {
349
+ $p = new Promise(function () use (&$p) { $p->resolve('a'); });
350
+ $p2 = $p
351
+ ->then(function ($v) { return $v . '-1-'; })
352
+ ->then(function ($v) { return $v . '2'; });
353
+ $this->assertEquals('a-1-2', $p2->wait());
354
+ }
355
+
356
+ public function testStacksThenWaitFunctions()
357
+ {
358
+ $p1 = new Promise(function () use (&$p1) { $p1->resolve('a'); });
359
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); });
360
+ $p3 = new Promise(function () use (&$p3) { $p3->resolve('c'); });
361
+ $p4 = $p1
362
+ ->then(function () use ($p2) { return $p2; })
363
+ ->then(function () use ($p3) { return $p3; });
364
+ $this->assertEquals('c', $p4->wait());
365
+ }
366
+
367
+ public function testForwardsFulfilledDownChainBetweenGaps()
368
+ {
369
+ $p = new Promise();
370
+ $r = $r2 = null;
371
+ $p->then(null, null)
372
+ ->then(function ($v) use (&$r) { $r = $v; return $v . '2'; })
373
+ ->then(function ($v) use (&$r2) { $r2 = $v; });
374
+ $p->resolve('foo');
375
+ P\queue()->run();
376
+ $this->assertEquals('foo', $r);
377
+ $this->assertEquals('foo2', $r2);
378
+ }
379
+
380
+ public function testForwardsRejectedPromisesDownChainBetweenGaps()
381
+ {
382
+ $p = new Promise();
383
+ $r = $r2 = null;
384
+ $p->then(null, null)
385
+ ->then(null, function ($v) use (&$r) { $r = $v; return $v . '2'; })
386
+ ->then(function ($v) use (&$r2) { $r2 = $v; });
387
+ $p->reject('foo');
388
+ P\queue()->run();
389
+ $this->assertEquals('foo', $r);
390
+ $this->assertEquals('foo2', $r2);
391
+ }
392
+
393
+ public function testForwardsThrownPromisesDownChainBetweenGaps()
394
+ {
395
+ $e = new \Exception();
396
+ $p = new Promise();
397
+ $r = $r2 = null;
398
+ $p->then(null, null)
399
+ ->then(null, function ($v) use (&$r, $e) {
400
+ $r = $v;
401
+ throw $e;
402
+ })
403
+ ->then(
404
+ null,
405
+ function ($v) use (&$r2) { $r2 = $v; }
406
+ );
407
+ $p->reject('foo');
408
+ P\queue()->run();
409
+ $this->assertEquals('foo', $r);
410
+ $this->assertSame($e, $r2);
411
+ }
412
+
413
+ public function testForwardsReturnedRejectedPromisesDownChainBetweenGaps()
414
+ {
415
+ $p = new Promise();
416
+ $rejected = new RejectedPromise('bar');
417
+ $r = $r2 = null;
418
+ $p->then(null, null)
419
+ ->then(null, function ($v) use (&$r, $rejected) {
420
+ $r = $v;
421
+ return $rejected;
422
+ })
423
+ ->then(
424
+ null,
425
+ function ($v) use (&$r2) { $r2 = $v; }
426
+ );
427
+ $p->reject('foo');
428
+ P\queue()->run();
429
+ $this->assertEquals('foo', $r);
430
+ $this->assertEquals('bar', $r2);
431
+ try {
432
+ $p->wait();
433
+ } catch (RejectionException $e) {
434
+ $this->assertEquals('foo', $e->getReason());
435
+ }
436
+ }
437
+
438
+ public function testForwardsHandlersToNextPromise()
439
+ {
440
+ $p = new Promise();
441
+ $p2 = new Promise();
442
+ $resolved = null;
443
+ $p
444
+ ->then(function ($v) use ($p2) { return $p2; })
445
+ ->then(function ($value) use (&$resolved) { $resolved = $value; });
446
+ $p->resolve('a');
447
+ $p2->resolve('b');
448
+ P\queue()->run();
449
+ $this->assertEquals('b', $resolved);
450
+ }
451
+
452
+ public function testRemovesReferenceFromChildWhenParentWaitedUpon()
453
+ {
454
+ $r = null;
455
+ $p = new Promise(function () use (&$p) { $p->resolve('a'); });
456
+ $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); });
457
+ $pb = $p->then(
458
+ function ($v) use ($p2, &$r) {
459
+ $r = $v;
460
+ return $p2;
461
+ })
462
+ ->then(function ($v) { return $v . '.'; });
463
+ $this->assertEquals('a', $p->wait());
464
+ $this->assertEquals('b', $p2->wait());
465
+ $this->assertEquals('b.', $pb->wait());
466
+ $this->assertEquals('a', $r);
467
+ }
468
+
469
+ public function testForwardsHandlersWhenFulfilledPromiseIsReturned()
470
+ {
471
+ $res = [];
472
+ $p = new Promise();
473
+ $p2 = new Promise();
474
+ $p2->resolve('foo');
475
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
476
+ // $res is A:foo
477
+ $p
478
+ ->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
479
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
480
+ $p->resolve('a');
481
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
482
+ P\queue()->run();
483
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
484
+ }
485
+
486
+ public function testForwardsHandlersWhenRejectedPromiseIsReturned()
487
+ {
488
+ $res = [];
489
+ $p = new Promise();
490
+ $p2 = new Promise();
491
+ $p2->reject('foo');
492
+ $p2->then(null, function ($v) use (&$res) { $res[] = 'A:' . $v; });
493
+ $p->then(null, function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
494
+ ->then(null, function ($v) use (&$res) { $res[] = 'C:' . $v; });
495
+ $p->reject('a');
496
+ $p->then(null, function ($v) use (&$res) { $res[] = 'D:' . $v; });
497
+ P\queue()->run();
498
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
499
+ }
500
+
501
+ public function testDoesNotForwardRejectedPromise()
502
+ {
503
+ $res = [];
504
+ $p = new Promise();
505
+ $p2 = new Promise();
506
+ $p2->cancel();
507
+ $p2->then(function ($v) use (&$res) { $res[] = "B:$v"; return $v; });
508
+ $p->then(function ($v) use ($p2, &$res) { $res[] = "B:$v"; return $p2; })
509
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
510
+ $p->resolve('a');
511
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
512
+ P\queue()->run();
513
+ $this->assertEquals(['B:a', 'D:a'], $res);
514
+ }
515
+
516
+ public function testRecursivelyForwardsWhenOnlyThennable()
517
+ {
518
+ $res = [];
519
+ $p = new Promise();
520
+ $p2 = new Thennable();
521
+ $p2->resolve('foo');
522
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
523
+ $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
524
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
525
+ $p->resolve('a');
526
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
527
+ P\queue()->run();
528
+ $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res);
529
+ }
530
+
531
+ public function testRecursivelyForwardsWhenNotInstanceOfPromise()
532
+ {
533
+ $res = [];
534
+ $p = new Promise();
535
+ $p2 = new NotPromiseInstance();
536
+ $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; });
537
+ $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; })
538
+ ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; });
539
+ $p->resolve('a');
540
+ $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; });
541
+ P\queue()->run();
542
+ $this->assertEquals(['B', 'D:a'], $res);
543
+ $p2->resolve('foo');
544
+ P\queue()->run();
545
+ $this->assertEquals(['B', 'D:a', 'A:foo', 'C:foo'], $res);
546
+ }
547
+
548
+ /**
549
+ * @expectedException \LogicException
550
+ * @expectedExceptionMessage Cannot fulfill or reject a promise with itself
551
+ */
552
+ public function testCannotResolveWithSelf()
553
+ {
554
+ $p = new Promise();
555
+ $p->resolve($p);
556
+ }
557
+
558
+ /**
559
+ * @expectedException \LogicException
560
+ * @expectedExceptionMessage Cannot fulfill or reject a promise with itself
561
+ */
562
+ public function testCannotRejectWithSelf()
563
+ {
564
+ $p = new Promise();
565
+ $p->reject($p);
566
+ }
567
+
568
+ public function testDoesNotBlowStackWhenWaitingOnNestedThens()
569
+ {
570
+ $inner = new Promise(function () use (&$inner) { $inner->resolve(0); });
571
+ $prev = $inner;
572
+ for ($i = 1; $i < 100; $i++) {
573
+ $prev = $prev->then(function ($i) { return $i + 1; });
574
+ }
575
+
576
+ $parent = new Promise(function () use (&$parent, $prev) {
577
+ $parent->resolve($prev);
578
+ });
579
+
580
+ $this->assertEquals(99, $parent->wait());
581
+ }
582
+
583
+ public function testOtherwiseIsSugarForRejections()
584
+ {
585
+ $p = new Promise();
586
+ $p->reject('foo');
587
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
588
+ P\queue()->run();
589
+ $this->assertEquals($c, 'foo');
590
+ }
591
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+ use GuzzleHttp\Promise\RejectedPromise;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Promise\RejectedPromise
9
+ */
10
+ class RejectedPromiseTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testThrowsReasonWhenWaitedUpon()
13
+ {
14
+ $p = new RejectedPromise('foo');
15
+ $this->assertEquals('rejected', $p->getState());
16
+ try {
17
+ $p->wait(true);
18
+ $this->fail();
19
+ } catch (\Exception $e) {
20
+ $this->assertEquals('rejected', $p->getState());
21
+ $this->assertContains('foo', $e->getMessage());
22
+ }
23
+ }
24
+
25
+ public function testCannotCancel()
26
+ {
27
+ $p = new RejectedPromise('foo');
28
+ $p->cancel();
29
+ $this->assertEquals('rejected', $p->getState());
30
+ }
31
+
32
+ /**
33
+ * @expectedException \LogicException
34
+ * @exepctedExceptionMessage Cannot resolve a rejected promise
35
+ */
36
+ public function testCannotResolve()
37
+ {
38
+ $p = new RejectedPromise('foo');
39
+ $p->resolve('bar');
40
+ }
41
+
42
+ /**
43
+ * @expectedException \LogicException
44
+ * @exepctedExceptionMessage Cannot reject a rejected promise
45
+ */
46
+ public function testCannotReject()
47
+ {
48
+ $p = new RejectedPromise('foo');
49
+ $p->reject('bar');
50
+ }
51
+
52
+ public function testCanRejectWithSameValue()
53
+ {
54
+ $p = new RejectedPromise('foo');
55
+ $p->reject('foo');
56
+ }
57
+
58
+ public function testThrowsSpecificException()
59
+ {
60
+ $e = new \Exception();
61
+ $p = new RejectedPromise($e);
62
+ try {
63
+ $p->wait(true);
64
+ $this->fail();
65
+ } catch (\Exception $e2) {
66
+ $this->assertSame($e, $e2);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @expectedException \InvalidArgumentException
72
+ */
73
+ public function testCannotResolveWithPromise()
74
+ {
75
+ new RejectedPromise(new Promise());
76
+ }
77
+
78
+ public function testReturnsSelfWhenNoOnReject()
79
+ {
80
+ $p = new RejectedPromise('a');
81
+ $this->assertSame($p, $p->then());
82
+ }
83
+
84
+ public function testInvokesOnRejectedAsynchronously()
85
+ {
86
+ $p = new RejectedPromise('a');
87
+ $r = null;
88
+ $f = function ($reason) use (&$r) { $r = $reason; };
89
+ $p->then(null, $f);
90
+ $this->assertNull($r);
91
+ \GuzzleHttp\Promise\queue()->run();
92
+ $this->assertEquals('a', $r);
93
+ }
94
+
95
+ public function testReturnsNewRejectedWhenOnRejectedFails()
96
+ {
97
+ $p = new RejectedPromise('a');
98
+ $f = function () { throw new \Exception('b'); };
99
+ $p2 = $p->then(null, $f);
100
+ $this->assertNotSame($p, $p2);
101
+ try {
102
+ $p2->wait();
103
+ $this->fail();
104
+ } catch (\Exception $e) {
105
+ $this->assertEquals('b', $e->getMessage());
106
+ }
107
+ }
108
+
109
+ public function testWaitingIsNoOp()
110
+ {
111
+ $p = new RejectedPromise('a');
112
+ $p->wait(false);
113
+ }
114
+
115
+ public function testOtherwiseIsSugarForRejections()
116
+ {
117
+ $p = new RejectedPromise('foo');
118
+ $p->otherwise(function ($v) use (&$c) { $c = $v; });
119
+ \GuzzleHttp\Promise\queue()->run();
120
+ $this->assertSame('foo', $c);
121
+ }
122
+
123
+ public function testCanResolveThenWithSuccess()
124
+ {
125
+ $actual = null;
126
+ $p = new RejectedPromise('foo');
127
+ $p->otherwise(function ($v) {
128
+ return $v . ' bar';
129
+ })->then(function ($v) use (&$actual) {
130
+ $actual = $v;
131
+ });
132
+ \GuzzleHttp\Promise\queue()->run();
133
+ $this->assertEquals('foo bar', $actual);
134
+ }
135
+
136
+ public function testDoesNotTryToRejectTwiceDuringTrampoline()
137
+ {
138
+ $fp = new RejectedPromise('a');
139
+ $t1 = $fp->then(null, function ($v) { return $v . ' b'; });
140
+ $t1->resolve('why!');
141
+ $this->assertEquals('why!', $t1->wait());
142
+ }
143
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\RejectionException;
5
+
6
+ class Thing1
7
+ {
8
+ public function __construct($message)
9
+ {
10
+ $this->message = $message;
11
+ }
12
+
13
+ public function __toString()
14
+ {
15
+ return $this->message;
16
+ }
17
+ }
18
+
19
+ class Thing2 implements \JsonSerializable
20
+ {
21
+ public function jsonSerialize()
22
+ {
23
+ return '{}';
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @covers GuzzleHttp\Promise\RejectionException
29
+ */
30
+ class RejectionExceptionTest extends \PHPUnit_Framework_TestCase
31
+ {
32
+ public function testCanGetReasonFromException()
33
+ {
34
+ $thing = new Thing1('foo');
35
+ $e = new RejectionException($thing);
36
+
37
+ $this->assertSame($thing, $e->getReason());
38
+ $this->assertEquals('The promise was rejected with reason: foo', $e->getMessage());
39
+ }
40
+
41
+ public function testCanGetReasonMessageFromJson()
42
+ {
43
+ $reason = new Thing2();
44
+ $e = new RejectionException($reason);
45
+ $this->assertContains("{}", $e->getMessage());
46
+ }
47
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/TaskQueueTest.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Test;
3
+
4
+ use GuzzleHttp\Promise\TaskQueue;
5
+
6
+ class TaskQueueTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testKnowsIfEmpty()
9
+ {
10
+ $tq = new TaskQueue(false);
11
+ $this->assertTrue($tq->isEmpty());
12
+ }
13
+
14
+ public function testKnowsIfFull()
15
+ {
16
+ $tq = new TaskQueue(false);
17
+ $tq->add(function () {});
18
+ $this->assertFalse($tq->isEmpty());
19
+ }
20
+
21
+ public function testExecutesTasksInOrder()
22
+ {
23
+ $tq = new TaskQueue(false);
24
+ $called = [];
25
+ $tq->add(function () use (&$called) { $called[] = 'a'; });
26
+ $tq->add(function () use (&$called) { $called[] = 'b'; });
27
+ $tq->add(function () use (&$called) { $called[] = 'c'; });
28
+ $tq->run();
29
+ $this->assertEquals(['a', 'b', 'c'], $called);
30
+ }
31
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/Thennable.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise\Promise;
5
+
6
+ class Thennable
7
+ {
8
+ private $nextPromise = null;
9
+
10
+ public function __construct()
11
+ {
12
+ $this->nextPromise = new Promise();
13
+ }
14
+
15
+ public function then(callable $res = null, callable $rej = null)
16
+ {
17
+ return $this->nextPromise->then($res, $rej);
18
+ }
19
+
20
+ public function resolve($value)
21
+ {
22
+ $this->nextPromise->resolve($value);
23
+ }
24
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/bootstrap.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ require __DIR__ . '/../vendor/autoload.php';
3
+ require __DIR__ . '/Thennable.php';
4
+ require __DIR__ . '/NotPromiseInstance.php';
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/promises/tests/functionsTest.php ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise\Tests;
3
+
4
+ use GuzzleHttp\Promise as P;
5
+ use GuzzleHttp\Promise\FulfilledPromise;
6
+ use GuzzleHttp\Promise\Promise;
7
+ use GuzzleHttp\Promise\RejectedPromise;
8
+
9
+ class FunctionsTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ public function testCreatesPromiseForValue()
12
+ {
13
+ $p = \GuzzleHttp\Promise\promise_for('foo');
14
+ $this->assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p);
15
+ }
16
+
17
+ public function testReturnsPromiseForPromise()
18
+ {
19
+ $p = new Promise();
20
+ $this->assertSame($p, \GuzzleHttp\Promise\promise_for($p));
21
+ }
22
+
23
+ public function testReturnsPromiseForThennable()
24
+ {
25
+ $p = new Thennable();
26
+ $wrapped = \GuzzleHttp\Promise\promise_for($p);
27
+ $this->assertNotSame($p, $wrapped);
28
+ $this->assertInstanceOf('GuzzleHttp\Promise\PromiseInterface', $wrapped);
29
+ $p->resolve('foo');
30
+ P\queue()->run();
31
+ $this->assertEquals('foo', $wrapped->wait());
32
+ }
33
+
34
+ public function testReturnsRejection()
35
+ {
36
+ $p = \GuzzleHttp\Promise\rejection_for('fail');
37
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p);
38
+ $this->assertEquals('fail', $this->readAttribute($p, 'reason'));
39
+ }
40
+
41
+ public function testReturnsPromisesAsIsInRejectionFor()
42
+ {
43
+ $a = new Promise();
44
+ $b = \GuzzleHttp\Promise\rejection_for($a);
45
+ $this->assertSame($a, $b);
46
+ }
47
+
48
+ public function testWaitsOnAllPromisesIntoArray()
49
+ {
50
+ $e = new \Exception();
51
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
52
+ $b = new Promise(function () use (&$b) { $b->reject('b'); });
53
+ $c = new Promise(function () use (&$c, $e) { $c->reject($e); });
54
+ $results = \GuzzleHttp\Promise\inspect_all([$a, $b, $c]);
55
+ $this->assertEquals([
56
+ ['state' => 'fulfilled', 'value' => 'a'],
57
+ ['state' => 'rejected', 'reason' => 'b'],
58
+ ['state' => 'rejected', 'reason' => $e]
59
+ ], $results);
60
+ }
61
+
62
+ /**
63
+ * @expectedException \GuzzleHttp\Promise\RejectionException
64
+ */
65
+ public function testUnwrapsPromisesWithNoDefaultAndFailure()
66
+ {
67
+ $promises = [new FulfilledPromise('a'), new Promise()];
68
+ \GuzzleHttp\Promise\unwrap($promises);
69
+ }
70
+
71
+ public function testUnwrapsPromisesWithNoDefault()
72
+ {
73
+ $promises = [new FulfilledPromise('a')];
74
+ $this->assertEquals(['a'], \GuzzleHttp\Promise\unwrap($promises));
75
+ }
76
+
77
+ public function testUnwrapsPromisesWithKeys()
78
+ {
79
+ $promises = [
80
+ 'foo' => new FulfilledPromise('a'),
81
+ 'bar' => new FulfilledPromise('b'),
82
+ ];
83
+ $this->assertEquals([
84
+ 'foo' => 'a',
85
+ 'bar' => 'b'
86
+ ], \GuzzleHttp\Promise\unwrap($promises));
87
+ }
88
+
89
+ public function testAllAggregatesSortedArray()
90
+ {
91
+ $a = new Promise();
92
+ $b = new Promise();
93
+ $c = new Promise();
94
+ $d = \GuzzleHttp\Promise\all([$a, $b, $c]);
95
+ $b->resolve('b');
96
+ $a->resolve('a');
97
+ $c->resolve('c');
98
+ $d->then(
99
+ function ($value) use (&$result) { $result = $value; },
100
+ function ($reason) use (&$result) { $result = $reason; }
101
+ );
102
+ P\queue()->run();
103
+ $this->assertEquals(['a', 'b', 'c'], $result);
104
+ }
105
+
106
+ public function testAllThrowsWhenAnyRejected()
107
+ {
108
+ $a = new Promise();
109
+ $b = new Promise();
110
+ $c = new Promise();
111
+ $d = \GuzzleHttp\Promise\all([$a, $b, $c]);
112
+ $b->resolve('b');
113
+ $a->reject('fail');
114
+ $c->resolve('c');
115
+ $d->then(
116
+ function ($value) use (&$result) { $result = $value; },
117
+ function ($reason) use (&$result) { $result = $reason; }
118
+ );
119
+ P\queue()->run();
120
+ $this->assertEquals('fail', $result);
121
+ }
122
+
123
+ public function testSomeAggregatesSortedArrayWithMax()
124
+ {
125
+ $a = new Promise();
126
+ $b = new Promise();
127
+ $c = new Promise();
128
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]);
129
+ $b->resolve('b');
130
+ $c->resolve('c');
131
+ $a->resolve('a');
132
+ $d->then(function ($value) use (&$result) { $result = $value; });
133
+ P\queue()->run();
134
+ $this->assertEquals(['b', 'c'], $result);
135
+ }
136
+
137
+ public function testSomeRejectsWhenTooManyRejections()
138
+ {
139
+ $a = new Promise();
140
+ $b = new Promise();
141
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b]);
142
+ $a->reject('bad');
143
+ $b->resolve('good');
144
+ P\queue()->run();
145
+ $this->assertEquals($a::REJECTED, $d->getState());
146
+ $d->then(null, function ($reason) use (&$called) {
147
+ $called = $reason;
148
+ });
149
+ P\queue()->run();
150
+ $this->assertInstanceOf('GuzzleHttp\Promise\AggregateException', $called);
151
+ $this->assertContains('bad', $called->getReason());
152
+ }
153
+
154
+ public function testCanWaitUntilSomeCountIsSatisfied()
155
+ {
156
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
157
+ $b = new Promise(function () use (&$b) { $b->resolve('b'); });
158
+ $c = new Promise(function () use (&$c) { $c->resolve('c'); });
159
+ $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]);
160
+ $this->assertEquals(['a', 'b'], $d->wait());
161
+ }
162
+
163
+ /**
164
+ * @expectedException \GuzzleHttp\Promise\AggregateException
165
+ * @expectedExceptionMessage Not enough promises to fulfill count
166
+ */
167
+ public function testThrowsIfImpossibleToWaitForSomeCount()
168
+ {
169
+ $a = new Promise(function () use (&$a) { $a->resolve('a'); });
170
+ $d = \GuzzleHttp\Promise\some(2, [$a]);
171
+ $d->wait();
172
+ }
173
+
174
+ /**
175
+ * @expectedException \GuzzleHttp\Promise\AggregateException
176
+ * @expectedExceptionMessage Not enough promises to fulfill count
177
+ */
178
+ public function testThrowsIfResolvedWithoutCountTotalResults()
179
+ {
180
+ $a = new Promise();
181
+ $b = new Promise();
182
+ $d = \GuzzleHttp\Promise\some(3, [$a, $b]);
183
+ $a->resolve('a');
184
+ $b->resolve('b');
185
+ $d->wait();
186
+ }
187
+
188
+ public function testAnyReturnsFirstMatch()
189
+ {
190
+ $a = new Promise();
191
+ $b = new Promise();
192
+ $c = \GuzzleHttp\Promise\any([$a, $b]);
193
+ $b->resolve('b');
194
+ $a->resolve('a');
195
+ //P\queue()->run();
196
+ //$this->assertEquals('fulfilled', $c->getState());
197
+ $c->then(function ($value) use (&$result) { $result = $value; });
198
+ P\queue()->run();
199
+ $this->assertEquals('b', $result);
200
+ }
201
+
202
+ public function testSettleFulfillsWithFulfilledAndRejected()
203
+ {
204
+ $a = new Promise();
205
+ $b = new Promise();
206
+ $c = new Promise();
207
+ $d = \GuzzleHttp\Promise\settle([$a, $b, $c]);
208
+ $b->resolve('b');
209
+ $c->resolve('c');
210
+ $a->reject('a');
211
+ P\queue()->run();
212
+ $this->assertEquals('fulfilled', $d->getState());
213
+ $d->then(function ($value) use (&$result) { $result = $value; });
214
+ P\queue()->run();
215
+ $this->assertEquals([
216
+ ['state' => 'rejected', 'reason' => 'a'],
217
+ ['state' => 'fulfilled', 'value' => 'b'],
218
+ ['state' => 'fulfilled', 'value' => 'c']
219
+ ], $result);
220
+ }
221
+
222
+ public function testCanInspectFulfilledPromise()
223
+ {
224
+ $p = new FulfilledPromise('foo');
225
+ $this->assertEquals([
226
+ 'state' => 'fulfilled',
227
+ 'value' => 'foo'
228
+ ], \GuzzleHttp\Promise\inspect($p));
229
+ }
230
+
231
+ public function testCanInspectRejectedPromise()
232
+ {
233
+ $p = new RejectedPromise('foo');
234
+ $this->assertEquals([
235
+ 'state' => 'rejected',
236
+ 'reason' => 'foo'
237
+ ], \GuzzleHttp\Promise\inspect($p));
238
+ }
239
+
240
+ public function testCanInspectRejectedPromiseWithNormalException()
241
+ {
242
+ $e = new \Exception('foo');
243
+ $p = new RejectedPromise($e);
244
+ $this->assertEquals([
245
+ 'state' => 'rejected',
246
+ 'reason' => $e
247
+ ], \GuzzleHttp\Promise\inspect($p));
248
+ }
249
+
250
+ public function testCallsEachLimit()
251
+ {
252
+ $p = new Promise();
253
+ $aggregate = \GuzzleHttp\Promise\each_limit($p, 2);
254
+ $p->resolve('a');
255
+ P\queue()->run();
256
+ $this->assertEquals($p::FULFILLED, $aggregate->getState());
257
+ }
258
+
259
+ public function testEachLimitAllRejectsOnFailure()
260
+ {
261
+ $p = [new FulfilledPromise('a'), new RejectedPromise('b')];
262
+ $aggregate = \GuzzleHttp\Promise\each_limit_all($p, 2);
263
+ P\queue()->run();
264
+ $this->assertEquals(P\PromiseInterface::REJECTED, $aggregate->getState());
265
+ $result = \GuzzleHttp\Promise\inspect($aggregate);
266
+ $this->assertEquals('b', $result['reason']);
267
+ }
268
+
269
+ public function testIterForReturnsIterator()
270
+ {
271
+ $iter = new \ArrayIterator();
272
+ $this->assertSame($iter, \GuzzleHttp\Promise\iter_for($iter));
273
+ }
274
+
275
+ public function testKnowsIfFulfilled()
276
+ {
277
+ $p = new FulfilledPromise(null);
278
+ $this->assertTrue(P\is_fulfilled($p));
279
+ $this->assertFalse(P\is_rejected($p));
280
+ }
281
+
282
+ public function testKnowsIfRejected()
283
+ {
284
+ $p = new RejectedPromise(null);
285
+ $this->assertTrue(P\is_rejected($p));
286
+ $this->assertFalse(P\is_fulfilled($p));
287
+ }
288
+
289
+ public function testKnowsIfSettled()
290
+ {
291
+ $p = new RejectedPromise(null);
292
+ $this->assertTrue(P\is_settled($p));
293
+ $p = new Promise();
294
+ $this->assertFalse(P\is_settled($p));
295
+ }
296
+
297
+ public function testReturnsTrampoline()
298
+ {
299
+ $this->assertInstanceOf('GuzzleHttp\Promise\TaskQueue', P\queue());
300
+ $this->assertSame(P\queue(), P\queue());
301
+ }
302
+
303
+ public function testCanScheduleThunk()
304
+ {
305
+ $tramp = P\queue();
306
+ $promise = P\task(function () { return 'Hi!'; });
307
+ $c = null;
308
+ $promise->then(function ($v) use (&$c) { $c = $v; });
309
+ $this->assertNull($c);
310
+ $tramp->run();
311
+ $this->assertEquals('Hi!', $c);
312
+ }
313
+
314
+ public function testCanScheduleThunkWithRejection()
315
+ {
316
+ $tramp = P\queue();
317
+ $promise = P\task(function () { throw new \Exception('Hi!'); });
318
+ $c = null;
319
+ $promise->otherwise(function ($v) use (&$c) { $c = $v; });
320
+ $this->assertNull($c);
321
+ $tramp->run();
322
+ $this->assertEquals('Hi!', $c->getMessage());
323
+ }
324
+
325
+ public function testCanScheduleThunkWithWait()
326
+ {
327
+ $tramp = P\queue();
328
+ $promise = P\task(function () { return 'a'; });
329
+ $this->assertEquals('a', $promise->wait());
330
+ $tramp->run();
331
+ }
332
+
333
+ public function testYieldsFromCoroutine()
334
+ {
335
+ $promise = P\coroutine(function () {
336
+ $value = (yield new P\FulfilledPromise('a'));
337
+ yield $value . 'b';
338
+ });
339
+ $promise->then(function ($value) use (&$result) { $result = $value; });
340
+ P\queue()->run();
341
+ $this->assertEquals('ab', $result);
342
+ }
343
+
344
+ public function testCanCatchExceptionsInCoroutine()
345
+ {
346
+ $promise = P\coroutine(function () {
347
+ try {
348
+ yield new P\RejectedPromise('a');
349
+ $this->fail('Should have thrown into the coroutine!');
350
+ } catch (P\RejectionException $e) {
351
+ $value = (yield new P\FulfilledPromise($e->getReason()));
352
+ yield $value . 'b';
353
+ }
354
+ });
355
+ $promise->then(function ($value) use (&$result) { $result = $value; });
356
+ P\queue()->run();
357
+ $this->assertEquals(P\PromiseInterface::FULFILLED, $promise->getState());
358
+ $this->assertEquals('ab', $result);
359
+ }
360
+
361
+ public function testRejectsParentExceptionWhenException()
362
+ {
363
+ $promise = P\coroutine(function () {
364
+ yield new P\FulfilledPromise(0);
365
+ throw new \Exception('a');
366
+ });
367
+ $promise->then(
368
+ function () { $this->fail(); },
369
+ function ($reason) use (&$result) { $result = $reason; }
370
+ );
371
+ P\queue()->run();
372
+ $this->assertInstanceOf('Exception', $result);
373
+ $this->assertEquals('a', $result->getMessage());
374
+ }
375
+
376
+ public function testCanRejectFromRejectionCallback()
377
+ {
378
+ $promise = P\coroutine(function () {
379
+ yield new P\FulfilledPromise(0);
380
+ yield new P\RejectedPromise('no!');
381
+ });
382
+ $promise->then(
383
+ function () { $this->fail(); },
384
+ function ($reason) use (&$result) { $result = $reason; }
385
+ );
386
+ P\queue()->run();
387
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result);
388
+ $this->assertEquals('no!', $result->getReason());
389
+ }
390
+
391
+ public function testCanAsyncReject()
392
+ {
393
+ $rej = new P\Promise();
394
+ $promise = P\coroutine(function () use ($rej) {
395
+ yield new P\FulfilledPromise(0);
396
+ yield $rej;
397
+ });
398
+ $promise->then(
399
+ function () { $this->fail(); },
400
+ function ($reason) use (&$result) { $result = $reason; }
401
+ );
402
+ $rej->reject('no!');
403
+ P\queue()->run();
404
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result);
405
+ $this->assertEquals('no!', $result->getReason());
406
+ }
407
+
408
+ public function testCanCatchAndThrowOtherException()
409
+ {
410
+ $promise = P\coroutine(function () {
411
+ try {
412
+ yield new P\RejectedPromise('a');
413
+ $this->fail('Should have thrown into the coroutine!');
414
+ } catch (P\RejectionException $e) {
415
+ throw new \Exception('foo');
416
+ }
417
+ });
418
+ $promise->otherwise(function ($value) use (&$result) { $result = $value; });
419
+ P\queue()->run();
420
+ $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState());
421
+ $this->assertContains('foo', $result->getMessage());
422
+ }
423
+
424
+ public function testCanCatchAndYieldOtherException()
425
+ {
426
+ $promise = P\coroutine(function () {
427
+ try {
428
+ yield new P\RejectedPromise('a');
429
+ $this->fail('Should have thrown into the coroutine!');
430
+ } catch (P\RejectionException $e) {
431
+ yield new P\RejectedPromise('foo');
432
+ }
433
+ });
434
+ $promise->otherwise(function ($value) use (&$result) { $result = $value; });
435
+ P\queue()->run();
436
+ $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState());
437
+ $this->assertContains('foo', $result->getMessage());
438
+ }
439
+
440
+ public function createLotsOfSynchronousPromise()
441
+ {
442
+ return P\coroutine(function () {
443
+ $value = 0;
444
+ for ($i = 0; $i < 1000; $i++) {
445
+ $value = (yield new P\FulfilledPromise($i));
446
+ }
447
+ yield $value;
448
+ });
449
+ }
450
+
451
+ public function testLotsOfSynchronousDoesNotBlowStack()
452
+ {
453
+ $promise = $this->createLotsOfSynchronousPromise();
454
+ $promise->then(function ($v) use (&$r) { $r = $v; });
455
+ P\queue()->run();
456
+ $this->assertEquals(999, $r);
457
+ }
458
+
459
+ public function testLotsOfSynchronousWaitDoesNotBlowStack()
460
+ {
461
+ $promise = $this->createLotsOfSynchronousPromise();
462
+ $promise->then(function ($v) use (&$r) { $r = $v; });
463
+ $this->assertEquals(999, $promise->wait());
464
+ $this->assertEquals(999, $r);
465
+ }
466
+
467
+ private function createLotsOfFlappingPromise()
468
+ {
469
+ return P\coroutine(function () {
470
+ $value = 0;
471
+ for ($i = 0; $i < 1000; $i++) {
472
+ try {
473
+ if ($i % 2) {
474
+ $value = (yield new P\FulfilledPromise($i));
475
+ } else {
476
+ $value = (yield new P\RejectedPromise($i));
477
+ }
478
+ } catch (\Exception $e) {
479
+ $value = (yield new P\FulfilledPromise($i));
480
+ }
481
+ }
482
+ yield $value;
483
+ });
484
+ }
485
+
486
+ public function testLotsOfTryCatchingDoesNotBlowStack()
487
+ {
488
+ $promise = $this->createLotsOfFlappingPromise();
489
+ $promise->then(function ($v) use (&$r) { $r = $v; });
490
+ P\queue()->run();
491
+ $this->assertEquals(999, $r);
492
+ }
493
+
494
+ public function testLotsOfTryCatchingWaitingDoesNotBlowStack()
495
+ {
496
+ $promise = $this->createLotsOfFlappingPromise();
497
+ $promise->then(function ($v) use (&$r) { $r = $v; });
498
+ $this->assertEquals(999, $promise->wait());
499
+ $this->assertEquals(999, $r);
500
+ }
501
+
502
+ public function testAsyncPromisesWithCorrectlyYieldedValues()
503
+ {
504
+ $promises = [
505
+ new P\Promise(),
506
+ new P\Promise(),
507
+ new P\Promise()
508
+ ];
509
+
510
+ $promise = P\coroutine(function () use ($promises) {
511
+ $value = null;
512
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
513
+ foreach ($promises as $idx => $p) {
514
+ $value = (yield $p);
515
+ $this->assertEquals($value, $idx);
516
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
517
+ }
518
+ $this->assertEquals('skip', (yield new P\FulfilledPromise('skip')));
519
+ yield $value;
520
+ });
521
+
522
+ $promises[0]->resolve(0);
523
+ $promises[1]->resolve(1);
524
+ $promises[2]->resolve(2);
525
+
526
+ $promise->then(function ($v) use (&$r) { $r = $v; });
527
+ P\queue()->run();
528
+ $this->assertEquals(2, $r);
529
+ }
530
+
531
+ public function testYieldFinalWaitablePromise()
532
+ {
533
+ $p1 = new P\Promise(function () use (&$p1) {
534
+ $p1->resolve('skip me');
535
+ });
536
+ $p2 = new P\Promise(function () use (&$p2) {
537
+ $p2->resolve('hello!');
538
+ });
539
+ $co = P\coroutine(function() use ($p1, $p2) {
540
+ yield $p1;
541
+ yield $p2;
542
+ });
543
+ P\queue()->run();
544
+ $this->assertEquals('hello!', $co->wait());
545
+ }
546
+
547
+ public function testCanYieldFinalPendingPromise()
548
+ {
549
+ $p1 = new P\Promise();
550
+ $p2 = new P\Promise();
551
+ $co = P\coroutine(function() use ($p1, $p2) {
552
+ yield $p1;
553
+ yield $p2;
554
+ });
555
+ $p1->resolve('a');
556
+ $p2->resolve('b');
557
+ $co->then(function ($value) use (&$result) { $result = $value; });
558
+ P\queue()->run();
559
+ $this->assertEquals('b', $result);
560
+ }
561
+
562
+ public function testCanNestYieldsAndFailures()
563
+ {
564
+ $p1 = new P\Promise();
565
+ $p2 = new P\Promise();
566
+ $p3 = new P\Promise();
567
+ $p4 = new P\Promise();
568
+ $p5 = new P\Promise();
569
+ $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5) {
570
+ try {
571
+ yield $p1;
572
+ } catch (\Exception $e) {
573
+ yield $p2;
574
+ try {
575
+ yield $p3;
576
+ yield $p4;
577
+ } catch (\Exception $e) {
578
+ yield $p5;
579
+ }
580
+ }
581
+ });
582
+ $p1->reject('a');
583
+ $p2->resolve('b');
584
+ $p3->resolve('c');
585
+ $p4->reject('d');
586
+ $p5->resolve('e');
587
+ $co->then(function ($value) use (&$result) { $result = $value; });
588
+ P\queue()->run();
589
+ $this->assertEquals('e', $result);
590
+ }
591
+
592
+ public function testCanYieldErrorsAndSuccessesWithoutRecursion()
593
+ {
594
+ $promises = [];
595
+ for ($i = 0; $i < 20; $i++) {
596
+ $promises[] = new P\Promise();
597
+ }
598
+
599
+ $co = P\coroutine(function() use ($promises) {
600
+ for ($i = 0; $i < 20; $i += 4) {
601
+ try {
602
+ yield $promises[$i];
603
+ yield $promises[$i + 1];
604
+ } catch (\Exception $e) {
605
+ yield $promises[$i + 2];
606
+ yield $promises[$i + 3];
607
+ }
608
+ }
609
+ });
610
+
611
+ for ($i = 0; $i < 20; $i += 4) {
612
+ $promises[$i]->resolve($i);
613
+ $promises[$i + 1]->reject($i + 1);
614
+ $promises[$i + 2]->resolve($i + 2);
615
+ $promises[$i + 3]->resolve($i + 3);
616
+ }
617
+
618
+ $co->then(function ($value) use (&$result) { $result = $value; });
619
+ P\queue()->run();
620
+ $this->assertEquals('19', $result);
621
+ }
622
+
623
+ public function testCanWaitOnPromiseAfterFulfilled()
624
+ {
625
+ $f = function () {
626
+ static $i = 0;
627
+ $i++;
628
+ return $p = new P\Promise(function () use (&$p, $i) {
629
+ $p->resolve($i . '-bar');
630
+ });
631
+ };
632
+
633
+ $promises = [];
634
+ for ($i = 0; $i < 20; $i++) {
635
+ $promises[] = $f();
636
+ }
637
+
638
+ $p = P\coroutine(function () use ($promises) {
639
+ yield new P\FulfilledPromise('foo!');
640
+ foreach ($promises as $promise) {
641
+ yield $promise;
642
+ }
643
+ });
644
+
645
+ $this->assertEquals('20-bar', $p->wait());
646
+ }
647
+
648
+ public function testCanWaitOnErroredPromises()
649
+ {
650
+ $p1 = new P\Promise(function () use (&$p1) { $p1->reject('a'); });
651
+ $p2 = new P\Promise(function () use (&$p2) { $p2->resolve('b'); });
652
+ $p3 = new P\Promise(function () use (&$p3) { $p3->resolve('c'); });
653
+ $p4 = new P\Promise(function () use (&$p4) { $p4->reject('d'); });
654
+ $p5 = new P\Promise(function () use (&$p5) { $p5->resolve('e'); });
655
+ $p6 = new P\Promise(function () use (&$p6) { $p6->reject('f'); });
656
+
657
+ $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5, $p6) {
658
+ try {
659
+ yield $p1;
660
+ } catch (\Exception $e) {
661
+ yield $p2;
662
+ try {
663
+ yield $p3;
664
+ yield $p4;
665
+ } catch (\Exception $e) {
666
+ yield $p5;
667
+ yield $p6;
668
+ }
669
+ }
670
+ });
671
+
672
+ $res = P\inspect($co);
673
+ $this->assertEquals('f', $res['reason']);
674
+ }
675
+
676
+ public function testCoroutineOtherwiseIntegrationTest()
677
+ {
678
+ $a = new P\Promise();
679
+ $b = new P\Promise();
680
+ $promise = P\coroutine(function () use ($a, $b) {
681
+ // Execute the pool of commands concurrently, and process errors.
682
+ yield $a;
683
+ yield $b;
684
+ })->otherwise(function (\Exception $e) {
685
+ // Throw errors from the operations as a specific Multipart error.
686
+ throw new \OutOfBoundsException('a', 0, $e);
687
+ });
688
+ $a->resolve('a');
689
+ $b->reject('b');
690
+ $reason = P\inspect($promise)['reason'];
691
+ $this->assertInstanceOf('OutOfBoundsException', $reason);
692
+ $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $reason->getPrevious());
693
+ }
694
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 1.3.1 - 2016-06-25
4
+
5
+ * Fix `Uri::__toString` for network path references, e.g. `//example.org`.
6
+ * Fix missing lowercase normalization for host.
7
+ * Fix handling of URI components in case they are `'0'` in a lot of places,
8
+ e.g. as a user info password.
9
+ * Fix `Uri::withAddedHeader` to correctly merge headers with different case.
10
+ * Fix trimming of header values in `Uri::withAddedHeader`. Header values may
11
+ be surrounded by whitespace which should be ignored according to RFC 7230
12
+ Section 3.2.4. This does not apply to header names.
13
+ * Fix `Uri::withAddedHeader` with an array of header values.
14
+ * Fix `Uri::resolve` when base path has no slash and handling of fragment.
15
+ * Fix handling of encoding in `Uri::with(out)QueryValue` so one can pass the
16
+ key/value both in encoded as well as decoded form to those methods. This is
17
+ consistent with withPath, withQuery etc.
18
+ * Fix `ServerRequest::withoutAttribute` when attribute value is null.
19
+
20
+ ## 1.3.0 - 2016-04-13
21
+
22
+ * Added remaining interfaces needed for full PSR7 compatibility
23
+ (ServerRequestInterface, UploadedFileInterface, etc.).
24
+ * Added support for stream_for from scalars.
25
+ * Can now extend Uri.
26
+ * Fixed a bug in validating request methods by making it more permissive.
27
+
28
+ ## 1.2.3 - 2016-02-18
29
+
30
+ * Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
31
+ streams, which can sometimes return fewer bytes than requested with `fread`.
32
+ * Fixed handling of gzipped responses with FNAME headers.
33
+
34
+ ## 1.2.2 - 2016-01-22
35
+
36
+ * Added support for URIs without any authority.
37
+ * Added support for HTTP 451 'Unavailable For Legal Reasons.'
38
+ * Added support for using '0' as a filename.
39
+ * Added support for including non-standard ports in Host headers.
40
+
41
+ ## 1.2.1 - 2015-11-02
42
+
43
+ * Now supporting negative offsets when seeking to SEEK_END.
44
+
45
+ ## 1.2.0 - 2015-08-15
46
+
47
+ * Body as `"0"` is now properly added to a response.
48
+ * Now allowing forward seeking in CachingStream.
49
+ * Now properly parsing HTTP requests that contain proxy targets in
50
+ `parse_request`.
51
+ * functions.php is now conditionally required.
52
+ * user-info is no longer dropped when resolving URIs.
53
+
54
+ ## 1.1.0 - 2015-06-24
55
+
56
+ * URIs can now be relative.
57
+ * `multipart/form-data` headers are now overridden case-insensitively.
58
+ * URI paths no longer encode the following characters because they are allowed
59
+ in URIs: "(", ")", "*", "!", "'"
60
+ * A port is no longer added to a URI when the scheme is missing and no port is
61
+ present.
62
+
63
+ ## 1.0.0 - 2015-05-19
64
+
65
+ Initial release.
66
+
67
+ Currently unsupported:
68
+
69
+ - `Psr\Http\Message\ServerRequestInterface`
70
+ - `Psr\Http\Message\UploadedFileInterface`
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/Makefile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit $(TEST)
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage $(TEST)
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ check-tag:
13
+ $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
14
+
15
+ tag: check-tag
16
+ @echo Tagging $(TAG)
17
+ chag update $(TAG)
18
+ git commit -a -m '$(TAG) release'
19
+ chag tag
20
+ @echo "Release has been created. Push using 'make release'"
21
+ @echo "Changes made in the release commit"
22
+ git diff HEAD~1 HEAD
23
+
24
+ release: check-tag
25
+ git push origin master
26
+ git push origin $(TAG)
27
+
28
+ clean:
29
+ rm -rf artifacts/*
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/README.md ADDED
@@ -0,0 +1,569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PSR-7 Message Implementation
2
+
3
+ This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
4
+ message implementation, several stream decorators, and some helpful
5
+ functionality like query string parsing.
6
+
7
+
8
+ [![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
9
+
10
+
11
+ # Stream implementation
12
+
13
+ This package comes with a number of stream implementations and stream
14
+ decorators.
15
+
16
+
17
+ ## AppendStream
18
+
19
+ `GuzzleHttp\Psr7\AppendStream`
20
+
21
+ Reads from multiple streams, one after the other.
22
+
23
+ ```php
24
+ use GuzzleHttp\Psr7;
25
+
26
+ $a = Psr7\stream_for('abc, ');
27
+ $b = Psr7\stream_for('123.');
28
+ $composed = new Psr7\AppendStream([$a, $b]);
29
+
30
+ $composed->addStream(Psr7\stream_for(' Above all listen to me'));
31
+
32
+ echo $composed; // abc, 123. Above all listen to me.
33
+ ```
34
+
35
+
36
+ ## BufferStream
37
+
38
+ `GuzzleHttp\Psr7\BufferStream`
39
+
40
+ Provides a buffer stream that can be written to fill a buffer, and read
41
+ from to remove bytes from the buffer.
42
+
43
+ This stream returns a "hwm" metadata value that tells upstream consumers
44
+ what the configured high water mark of the stream is, or the maximum
45
+ preferred size of the buffer.
46
+
47
+ ```php
48
+ use GuzzleHttp\Psr7;
49
+
50
+ // When more than 1024 bytes are in the buffer, it will begin returning
51
+ // false to writes. This is an indication that writers should slow down.
52
+ $buffer = new Psr7\BufferStream(1024);
53
+ ```
54
+
55
+
56
+ ## CachingStream
57
+
58
+ The CachingStream is used to allow seeking over previously read bytes on
59
+ non-seekable streams. This can be useful when transferring a non-seekable
60
+ entity body fails due to needing to rewind the stream (for example, resulting
61
+ from a redirect). Data that is read from the remote stream will be buffered in
62
+ a PHP temp stream so that previously read bytes are cached first in memory,
63
+ then on disk.
64
+
65
+ ```php
66
+ use GuzzleHttp\Psr7;
67
+
68
+ $original = Psr7\stream_for(fopen('http://www.google.com', 'r'));
69
+ $stream = new Psr7\CachingStream($original);
70
+
71
+ $stream->read(1024);
72
+ echo $stream->tell();
73
+ // 1024
74
+
75
+ $stream->seek(0);
76
+ echo $stream->tell();
77
+ // 0
78
+ ```
79
+
80
+
81
+ ## DroppingStream
82
+
83
+ `GuzzleHttp\Psr7\DroppingStream`
84
+
85
+ Stream decorator that begins dropping data once the size of the underlying
86
+ stream becomes too full.
87
+
88
+ ```php
89
+ use GuzzleHttp\Psr7;
90
+
91
+ // Create an empty stream
92
+ $stream = Psr7\stream_for();
93
+
94
+ // Start dropping data when the stream has more than 10 bytes
95
+ $dropping = new Psr7\DroppingStream($stream, 10);
96
+
97
+ $dropping->write('01234567890123456789');
98
+ echo $stream; // 0123456789
99
+ ```
100
+
101
+
102
+ ## FnStream
103
+
104
+ `GuzzleHttp\Psr7\FnStream`
105
+
106
+ Compose stream implementations based on a hash of functions.
107
+
108
+ Allows for easy testing and extension of a provided stream without needing
109
+ to create a concrete class for a simple extension point.
110
+
111
+ ```php
112
+
113
+ use GuzzleHttp\Psr7;
114
+
115
+ $stream = Psr7\stream_for('hi');
116
+ $fnStream = Psr7\FnStream::decorate($stream, [
117
+ 'rewind' => function () use ($stream) {
118
+ echo 'About to rewind - ';
119
+ $stream->rewind();
120
+ echo 'rewound!';
121
+ }
122
+ ]);
123
+
124
+ $fnStream->rewind();
125
+ // Outputs: About to rewind - rewound!
126
+ ```
127
+
128
+
129
+ ## InflateStream
130
+
131
+ `GuzzleHttp\Psr7\InflateStream`
132
+
133
+ Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
134
+
135
+ This stream decorator skips the first 10 bytes of the given stream to remove
136
+ the gzip header, converts the provided stream to a PHP stream resource,
137
+ then appends the zlib.inflate filter. The stream is then converted back
138
+ to a Guzzle stream resource to be used as a Guzzle stream.
139
+
140
+
141
+ ## LazyOpenStream
142
+
143
+ `GuzzleHttp\Psr7\LazyOpenStream`
144
+
145
+ Lazily reads or writes to a file that is opened only after an IO operation
146
+ take place on the stream.
147
+
148
+ ```php
149
+ use GuzzleHttp\Psr7;
150
+
151
+ $stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
152
+ // The file has not yet been opened...
153
+
154
+ echo $stream->read(10);
155
+ // The file is opened and read from only when needed.
156
+ ```
157
+
158
+
159
+ ## LimitStream
160
+
161
+ `GuzzleHttp\Psr7\LimitStream`
162
+
163
+ LimitStream can be used to read a subset or slice of an existing stream object.
164
+ This can be useful for breaking a large file into smaller pieces to be sent in
165
+ chunks (e.g. Amazon S3's multipart upload API).
166
+
167
+ ```php
168
+ use GuzzleHttp\Psr7;
169
+
170
+ $original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
171
+ echo $original->getSize();
172
+ // >>> 1048576
173
+
174
+ // Limit the size of the body to 1024 bytes and start reading from byte 2048
175
+ $stream = new Psr7\LimitStream($original, 1024, 2048);
176
+ echo $stream->getSize();
177
+ // >>> 1024
178
+ echo $stream->tell();
179
+ // >>> 0
180
+ ```
181
+
182
+
183
+ ## MultipartStream
184
+
185
+ `GuzzleHttp\Psr7\MultipartStream`
186
+
187
+ Stream that when read returns bytes for a streaming multipart or
188
+ multipart/form-data stream.
189
+
190
+
191
+ ## NoSeekStream
192
+
193
+ `GuzzleHttp\Psr7\NoSeekStream`
194
+
195
+ NoSeekStream wraps a stream and does not allow seeking.
196
+
197
+ ```php
198
+ use GuzzleHttp\Psr7;
199
+
200
+ $original = Psr7\stream_for('foo');
201
+ $noSeek = new Psr7\NoSeekStream($original);
202
+
203
+ echo $noSeek->read(3);
204
+ // foo
205
+ var_export($noSeek->isSeekable());
206
+ // false
207
+ $noSeek->seek(0);
208
+ var_export($noSeek->read(3));
209
+ // NULL
210
+ ```
211
+
212
+
213
+ ## PumpStream
214
+
215
+ `GuzzleHttp\Psr7\PumpStream`
216
+
217
+ Provides a read only stream that pumps data from a PHP callable.
218
+
219
+ When invoking the provided callable, the PumpStream will pass the amount of
220
+ data requested to read to the callable. The callable can choose to ignore
221
+ this value and return fewer or more bytes than requested. Any extra data
222
+ returned by the provided callable is buffered internally until drained using
223
+ the read() function of the PumpStream. The provided callable MUST return
224
+ false when there is no more data to read.
225
+
226
+
227
+ ## Implementing stream decorators
228
+
229
+ Creating a stream decorator is very easy thanks to the
230
+ `GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
231
+ implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
232
+ stream. Just `use` the `StreamDecoratorTrait` and implement your custom
233
+ methods.
234
+
235
+ For example, let's say we wanted to call a specific function each time the last
236
+ byte is read from a stream. This could be implemented by overriding the
237
+ `read()` method.
238
+
239
+ ```php
240
+ use Psr\Http\Message\StreamInterface;
241
+ use GuzzleHttp\Psr7\StreamDecoratorTrait;
242
+
243
+ class EofCallbackStream implements StreamInterface
244
+ {
245
+ use StreamDecoratorTrait;
246
+
247
+ private $callback;
248
+
249
+ public function __construct(StreamInterface $stream, callable $cb)
250
+ {
251
+ $this->stream = $stream;
252
+ $this->callback = $cb;
253
+ }
254
+
255
+ public function read($length)
256
+ {
257
+ $result = $this->stream->read($length);
258
+
259
+ // Invoke the callback when EOF is hit.
260
+ if ($this->eof()) {
261
+ call_user_func($this->callback);
262
+ }
263
+
264
+ return $result;
265
+ }
266
+ }
267
+ ```
268
+
269
+ This decorator could be added to any existing stream and used like so:
270
+
271
+ ```php
272
+ use GuzzleHttp\Psr7;
273
+
274
+ $original = Psr7\stream_for('foo');
275
+
276
+ $eofStream = new EofCallbackStream($original, function () {
277
+ echo 'EOF!';
278
+ });
279
+
280
+ $eofStream->read(2);
281
+ $eofStream->read(1);
282
+ // echoes "EOF!"
283
+ $eofStream->seek(0);
284
+ $eofStream->read(3);
285
+ // echoes "EOF!"
286
+ ```
287
+
288
+
289
+ ## PHP StreamWrapper
290
+
291
+ You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
292
+ PSR-7 stream as a PHP stream resource.
293
+
294
+ Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
295
+ stream from a PSR-7 stream.
296
+
297
+ ```php
298
+ use GuzzleHttp\Psr7\StreamWrapper;
299
+
300
+ $stream = GuzzleHttp\Psr7\stream_for('hello!');
301
+ $resource = StreamWrapper::getResource($stream);
302
+ echo fread($resource, 6); // outputs hello!
303
+ ```
304
+
305
+
306
+ # Function API
307
+
308
+ There are various functions available under the `GuzzleHttp\Psr7` namespace.
309
+
310
+
311
+ ## `function str`
312
+
313
+ `function str(MessageInterface $message)`
314
+
315
+ Returns the string representation of an HTTP message.
316
+
317
+ ```php
318
+ $request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
319
+ echo GuzzleHttp\Psr7\str($request);
320
+ ```
321
+
322
+
323
+ ## `function uri_for`
324
+
325
+ `function uri_for($uri)`
326
+
327
+ This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
328
+ UriInterface for the given value. If the value is already a `UriInterface`, it
329
+ is returned as-is.
330
+
331
+ ```php
332
+ $uri = GuzzleHttp\Psr7\uri_for('http://example.com');
333
+ assert($uri === GuzzleHttp\Psr7\uri_for($uri));
334
+ ```
335
+
336
+
337
+ ## `function stream_for`
338
+
339
+ `function stream_for($resource = '', array $options = [])`
340
+
341
+ Create a new stream based on the input type.
342
+
343
+ Options is an associative array that can contain the following keys:
344
+
345
+ * - metadata: Array of custom metadata.
346
+ * - size: Size of the stream.
347
+
348
+ This method accepts the following `$resource` types:
349
+
350
+ - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
351
+ - `string`: Creates a stream object that uses the given string as the contents.
352
+ - `resource`: Creates a stream object that wraps the given PHP stream resource.
353
+ - `Iterator`: If the provided value implements `Iterator`, then a read-only
354
+ stream object will be created that wraps the given iterable. Each time the
355
+ stream is read from, data from the iterator will fill a buffer and will be
356
+ continuously called until the buffer is equal to the requested read size.
357
+ Subsequent read calls will first read from the buffer and then call `next`
358
+ on the underlying iterator until it is exhausted.
359
+ - `object` with `__toString()`: If the object has the `__toString()` method,
360
+ the object will be cast to a string and then a stream will be returned that
361
+ uses the string value.
362
+ - `NULL`: When `null` is passed, an empty stream object is returned.
363
+ - `callable` When a callable is passed, a read-only stream object will be
364
+ created that invokes the given callable. The callable is invoked with the
365
+ number of suggested bytes to read. The callable can return any number of
366
+ bytes, but MUST return `false` when there is no more data to return. The
367
+ stream object that wraps the callable will invoke the callable until the
368
+ number of requested bytes are available. Any additional bytes will be
369
+ buffered and used in subsequent reads.
370
+
371
+ ```php
372
+ $stream = GuzzleHttp\Psr7\stream_for('foo');
373
+ $stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r'));
374
+
375
+ $generator function ($bytes) {
376
+ for ($i = 0; $i < $bytes; $i++) {
377
+ yield ' ';
378
+ }
379
+ }
380
+
381
+ $stream = GuzzleHttp\Psr7\stream_for($generator(100));
382
+ ```
383
+
384
+
385
+ ## `function parse_header`
386
+
387
+ `function parse_header($header)`
388
+
389
+ Parse an array of header values containing ";" separated data into an array of
390
+ associative arrays representing the header key value pair data of the header.
391
+ When a parameter does not contain a value, but just contains a key, this
392
+ function will inject a key with a '' string value.
393
+
394
+
395
+ ## `function normalize_header`
396
+
397
+ `function normalize_header($header)`
398
+
399
+ Converts an array of header values that may contain comma separated headers
400
+ into an array of headers with no comma separated values.
401
+
402
+
403
+ ## `function modify_request`
404
+
405
+ `function modify_request(RequestInterface $request, array $changes)`
406
+
407
+ Clone and modify a request with the given changes. This method is useful for
408
+ reducing the number of clones needed to mutate a message.
409
+
410
+ The changes can be one of:
411
+
412
+ - method: (string) Changes the HTTP method.
413
+ - set_headers: (array) Sets the given headers.
414
+ - remove_headers: (array) Remove the given headers.
415
+ - body: (mixed) Sets the given body.
416
+ - uri: (UriInterface) Set the URI.
417
+ - query: (string) Set the query string value of the URI.
418
+ - version: (string) Set the protocol version.
419
+
420
+
421
+ ## `function rewind_body`
422
+
423
+ `function rewind_body(MessageInterface $message)`
424
+
425
+ Attempts to rewind a message body and throws an exception on failure. The body
426
+ of the message will only be rewound if a call to `tell()` returns a value other
427
+ than `0`.
428
+
429
+
430
+ ## `function try_fopen`
431
+
432
+ `function try_fopen($filename, $mode)`
433
+
434
+ Safely opens a PHP stream resource using a filename.
435
+
436
+ When fopen fails, PHP normally raises a warning. This function adds an error
437
+ handler that checks for errors and throws an exception instead.
438
+
439
+
440
+ ## `function copy_to_string`
441
+
442
+ `function copy_to_string(StreamInterface $stream, $maxLen = -1)`
443
+
444
+ Copy the contents of a stream into a string until the given number of bytes
445
+ have been read.
446
+
447
+
448
+ ## `function copy_to_stream`
449
+
450
+ `function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)`
451
+
452
+ Copy the contents of a stream into another stream until the given number of
453
+ bytes have been read.
454
+
455
+
456
+ ## `function hash`
457
+
458
+ `function hash(StreamInterface $stream, $algo, $rawOutput = false)`
459
+
460
+ Calculate a hash of a Stream. This method reads the entire stream to calculate
461
+ a rolling hash (based on PHP's hash_init functions).
462
+
463
+
464
+ ## `function readline`
465
+
466
+ `function readline(StreamInterface $stream, $maxLength = null)`
467
+
468
+ Read a line from the stream up to the maximum allowed buffer length.
469
+
470
+
471
+ ## `function parse_request`
472
+
473
+ `function parse_request($message)`
474
+
475
+ Parses a request message string into a request object.
476
+
477
+
478
+ ## `function parse_response`
479
+
480
+ `function parse_response($message)`
481
+
482
+ Parses a response message string into a response object.
483
+
484
+
485
+ ## `function parse_query`
486
+
487
+ `function parse_query($str, $urlEncoding = true)`
488
+
489
+ Parse a query string into an associative array.
490
+
491
+ If multiple values are found for the same key, the value of that key value pair
492
+ will become an array. This function does not parse nested PHP style arrays into
493
+ an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into
494
+ `['foo[a]' => '1', 'foo[b]' => '2']`).
495
+
496
+
497
+ ## `function build_query`
498
+
499
+ `function build_query(array $params, $encoding = PHP_QUERY_RFC3986)`
500
+
501
+ Build a query string from an array of key value pairs.
502
+
503
+ This function can use the return value of parse_query() to build a query string.
504
+ This function does not modify the provided keys when an array is encountered
505
+ (like http_build_query would).
506
+
507
+
508
+ ## `function mimetype_from_filename`
509
+
510
+ `function mimetype_from_filename($filename)`
511
+
512
+ Determines the mimetype of a file by looking at its extension.
513
+
514
+
515
+ ## `function mimetype_from_extension`
516
+
517
+ `function mimetype_from_extension($extension)`
518
+
519
+ Maps a file extensions to a mimetype.
520
+
521
+
522
+ # Static URI methods
523
+
524
+ The `GuzzleHttp\Psr7\Uri` class has several static methods to manipulate URIs.
525
+
526
+
527
+ ## `GuzzleHttp\Psr7\Uri::removeDotSegments`
528
+
529
+ `public static function removeDotSegments(string $path): string`
530
+
531
+ Removes dot segments from a path and returns the new path.
532
+
533
+ See http://tools.ietf.org/html/rfc3986#section-5.2.4
534
+
535
+
536
+ ## `GuzzleHttp\Psr7\Uri::resolve`
537
+
538
+ `public static function resolve(UriInterface $base, $rel): UriInterface`
539
+
540
+ Resolve a base URI with a relative URI and return a new URI.
541
+
542
+ See http://tools.ietf.org/html/rfc3986#section-5
543
+
544
+
545
+ ## `GuzzleHttp\Psr7\Uri::withQueryValue`
546
+
547
+ `public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
548
+
549
+ Create a new URI with a specific query string value.
550
+
551
+ Any existing query string values that exactly match the provided key are
552
+ removed and replaced with the given key value pair.
553
+
554
+
555
+ ## `GuzzleHttp\Psr7\Uri::withoutQueryValue`
556
+
557
+ `public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
558
+
559
+ Create a new URI with a specific query string value removed.
560
+
561
+ Any existing query string values that exactly match the provided key are
562
+ removed.
563
+
564
+
565
+ ## `GuzzleHttp\Psr7\Uri::fromParts`
566
+
567
+ `public static function fromParts(array $parts): UriInterface`
568
+
569
+ Create a `GuzzleHttp\Psr7\Uri` object from a hash of `parse_url` parts.
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/composer.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/psr7",
3
+ "type": "library",
4
+ "description": "PSR-7 message implementation",
5
+ "keywords": ["message", "stream", "http", "uri"],
6
+ "license": "MIT",
7
+ "authors": [
8
+ {
9
+ "name": "Michael Dowling",
10
+ "email": "mtdowling@gmail.com",
11
+ "homepage": "https://github.com/mtdowling"
12
+ }
13
+ ],
14
+ "require": {
15
+ "php": ">=5.4.0",
16
+ "psr/http-message": "~1.0"
17
+ },
18
+ "require-dev": {
19
+ "phpunit/phpunit": "~4.0"
20
+ },
21
+ "provide": {
22
+ "psr/http-message-implementation": "1.0"
23
+ },
24
+ "autoload": {
25
+ "psr-4": {
26
+ "GuzzleHttp\\Psr7\\": "src/"
27
+ },
28
+ "files": ["src/functions_include.php"]
29
+ },
30
+ "extra": {
31
+ "branch-alias": {
32
+ "dev-master": "1.4-dev"
33
+ }
34
+ }
35
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./tests/bootstrap.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ <exclude>
13
+ <directory suffix="Interface.php">src/</directory>
14
+ </exclude>
15
+ </whitelist>
16
+ </filter>
17
+ </phpunit>
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/AppendStream.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Reads from multiple streams, one after the other.
8
+ *
9
+ * This is a read-only stream decorator.
10
+ */
11
+ class AppendStream implements StreamInterface
12
+ {
13
+ /** @var StreamInterface[] Streams being decorated */
14
+ private $streams = [];
15
+
16
+ private $seekable = true;
17
+ private $current = 0;
18
+ private $pos = 0;
19
+ private $detached = false;
20
+
21
+ /**
22
+ * @param StreamInterface[] $streams Streams to decorate. Each stream must
23
+ * be readable.
24
+ */
25
+ public function __construct(array $streams = [])
26
+ {
27
+ foreach ($streams as $stream) {
28
+ $this->addStream($stream);
29
+ }
30
+ }
31
+
32
+ public function __toString()
33
+ {
34
+ try {
35
+ $this->rewind();
36
+ return $this->getContents();
37
+ } catch (\Exception $e) {
38
+ return '';
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Add a stream to the AppendStream
44
+ *
45
+ * @param StreamInterface $stream Stream to append. Must be readable.
46
+ *
47
+ * @throws \InvalidArgumentException if the stream is not readable
48
+ */
49
+ public function addStream(StreamInterface $stream)
50
+ {
51
+ if (!$stream->isReadable()) {
52
+ throw new \InvalidArgumentException('Each stream must be readable');
53
+ }
54
+
55
+ // The stream is only seekable if all streams are seekable
56
+ if (!$stream->isSeekable()) {
57
+ $this->seekable = false;
58
+ }
59
+
60
+ $this->streams[] = $stream;
61
+ }
62
+
63
+ public function getContents()
64
+ {
65
+ return copy_to_string($this);
66
+ }
67
+
68
+ /**
69
+ * Closes each attached stream.
70
+ *
71
+ * {@inheritdoc}
72
+ */
73
+ public function close()
74
+ {
75
+ $this->pos = $this->current = 0;
76
+
77
+ foreach ($this->streams as $stream) {
78
+ $stream->close();
79
+ }
80
+
81
+ $this->streams = [];
82
+ }
83
+
84
+ /**
85
+ * Detaches each attached stream
86
+ *
87
+ * {@inheritdoc}
88
+ */
89
+ public function detach()
90
+ {
91
+ $this->close();
92
+ $this->detached = true;
93
+ }
94
+
95
+ public function tell()
96
+ {
97
+ return $this->pos;
98
+ }
99
+
100
+ /**
101
+ * Tries to calculate the size by adding the size of each stream.
102
+ *
103
+ * If any of the streams do not return a valid number, then the size of the
104
+ * append stream cannot be determined and null is returned.
105
+ *
106
+ * {@inheritdoc}
107
+ */
108
+ public function getSize()
109
+ {
110
+ $size = 0;
111
+
112
+ foreach ($this->streams as $stream) {
113
+ $s = $stream->getSize();
114
+ if ($s === null) {
115
+ return null;
116
+ }
117
+ $size += $s;
118
+ }
119
+
120
+ return $size;
121
+ }
122
+
123
+ public function eof()
124
+ {
125
+ return !$this->streams ||
126
+ ($this->current >= count($this->streams) - 1 &&
127
+ $this->streams[$this->current]->eof());
128
+ }
129
+
130
+ public function rewind()
131
+ {
132
+ $this->seek(0);
133
+ }
134
+
135
+ /**
136
+ * Attempts to seek to the given position. Only supports SEEK_SET.
137
+ *
138
+ * {@inheritdoc}
139
+ */
140
+ public function seek($offset, $whence = SEEK_SET)
141
+ {
142
+ if (!$this->seekable) {
143
+ throw new \RuntimeException('This AppendStream is not seekable');
144
+ } elseif ($whence !== SEEK_SET) {
145
+ throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
146
+ }
147
+
148
+ $this->pos = $this->current = 0;
149
+
150
+ // Rewind each stream
151
+ foreach ($this->streams as $i => $stream) {
152
+ try {
153
+ $stream->rewind();
154
+ } catch (\Exception $e) {
155
+ throw new \RuntimeException('Unable to seek stream '
156
+ . $i . ' of the AppendStream', 0, $e);
157
+ }
158
+ }
159
+
160
+ // Seek to the actual position by reading from each stream
161
+ while ($this->pos < $offset && !$this->eof()) {
162
+ $result = $this->read(min(8096, $offset - $this->pos));
163
+ if ($result === '') {
164
+ break;
165
+ }
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Reads from all of the appended streams until the length is met or EOF.
171
+ *
172
+ * {@inheritdoc}
173
+ */
174
+ public function read($length)
175
+ {
176
+ $buffer = '';
177
+ $total = count($this->streams) - 1;
178
+ $remaining = $length;
179
+ $progressToNext = false;
180
+
181
+ while ($remaining > 0) {
182
+
183
+ // Progress to the next stream if needed.
184
+ if ($progressToNext || $this->streams[$this->current]->eof()) {
185
+ $progressToNext = false;
186
+ if ($this->current === $total) {
187
+ break;
188
+ }
189
+ $this->current++;
190
+ }
191
+
192
+ $result = $this->streams[$this->current]->read($remaining);
193
+
194
+ // Using a loose comparison here to match on '', false, and null
195
+ if ($result == null) {
196
+ $progressToNext = true;
197
+ continue;
198
+ }
199
+
200
+ $buffer .= $result;
201
+ $remaining = $length - strlen($buffer);
202
+ }
203
+
204
+ $this->pos += strlen($buffer);
205
+
206
+ return $buffer;
207
+ }
208
+
209
+ public function isReadable()
210
+ {
211
+ return true;
212
+ }
213
+
214
+ public function isWritable()
215
+ {
216
+ return false;
217
+ }
218
+
219
+ public function isSeekable()
220
+ {
221
+ return $this->seekable;
222
+ }
223
+
224
+ public function write($string)
225
+ {
226
+ throw new \RuntimeException('Cannot write to an AppendStream');
227
+ }
228
+
229
+ public function getMetadata($key = null)
230
+ {
231
+ return $key ? null : [];
232
+ }
233
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/BufferStream.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Provides a buffer stream that can be written to to fill a buffer, and read
8
+ * from to remove bytes from the buffer.
9
+ *
10
+ * This stream returns a "hwm" metadata value that tells upstream consumers
11
+ * what the configured high water mark of the stream is, or the maximum
12
+ * preferred size of the buffer.
13
+ */
14
+ class BufferStream implements StreamInterface
15
+ {
16
+ private $hwm;
17
+ private $buffer = '';
18
+
19
+ /**
20
+ * @param int $hwm High water mark, representing the preferred maximum
21
+ * buffer size. If the size of the buffer exceeds the high
22
+ * water mark, then calls to write will continue to succeed
23
+ * but will return false to inform writers to slow down
24
+ * until the buffer has been drained by reading from it.
25
+ */
26
+ public function __construct($hwm = 16384)
27
+ {
28
+ $this->hwm = $hwm;
29
+ }
30
+
31
+ public function __toString()
32
+ {
33
+ return $this->getContents();
34
+ }
35
+
36
+ public function getContents()
37
+ {
38
+ $buffer = $this->buffer;
39
+ $this->buffer = '';
40
+
41
+ return $buffer;
42
+ }
43
+
44
+ public function close()
45
+ {
46
+ $this->buffer = '';
47
+ }
48
+
49
+ public function detach()
50
+ {
51
+ $this->close();
52
+ }
53
+
54
+ public function getSize()
55
+ {
56
+ return strlen($this->buffer);
57
+ }
58
+
59
+ public function isReadable()
60
+ {
61
+ return true;
62
+ }
63
+
64
+ public function isWritable()
65
+ {
66
+ return true;
67
+ }
68
+
69
+ public function isSeekable()
70
+ {
71
+ return false;
72
+ }
73
+
74
+ public function rewind()
75
+ {
76
+ $this->seek(0);
77
+ }
78
+
79
+ public function seek($offset, $whence = SEEK_SET)
80
+ {
81
+ throw new \RuntimeException('Cannot seek a BufferStream');
82
+ }
83
+
84
+ public function eof()
85
+ {
86
+ return strlen($this->buffer) === 0;
87
+ }
88
+
89
+ public function tell()
90
+ {
91
+ throw new \RuntimeException('Cannot determine the position of a BufferStream');
92
+ }
93
+
94
+ /**
95
+ * Reads data from the buffer.
96
+ */
97
+ public function read($length)
98
+ {
99
+ $currentLength = strlen($this->buffer);
100
+
101
+ if ($length >= $currentLength) {
102
+ // No need to slice the buffer because we don't have enough data.
103
+ $result = $this->buffer;
104
+ $this->buffer = '';
105
+ } else {
106
+ // Slice up the result to provide a subset of the buffer.
107
+ $result = substr($this->buffer, 0, $length);
108
+ $this->buffer = substr($this->buffer, $length);
109
+ }
110
+
111
+ return $result;
112
+ }
113
+
114
+ /**
115
+ * Writes data to the buffer.
116
+ */
117
+ public function write($string)
118
+ {
119
+ $this->buffer .= $string;
120
+
121
+ // TODO: What should happen here?
122
+ if (strlen($this->buffer) >= $this->hwm) {
123
+ return false;
124
+ }
125
+
126
+ return strlen($string);
127
+ }
128
+
129
+ public function getMetadata($key = null)
130
+ {
131
+ if ($key == 'hwm') {
132
+ return $this->hwm;
133
+ }
134
+
135
+ return $key ? null : [];
136
+ }
137
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/CachingStream.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that can cache previously read bytes from a sequentially
8
+ * read stream.
9
+ */
10
+ class CachingStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var StreamInterface Stream being wrapped */
15
+ private $remoteStream;
16
+
17
+ /** @var int Number of bytes to skip reading due to a write on the buffer */
18
+ private $skipReadBytes = 0;
19
+
20
+ /**
21
+ * We will treat the buffer object as the body of the stream
22
+ *
23
+ * @param StreamInterface $stream Stream to cache
24
+ * @param StreamInterface $target Optionally specify where data is cached
25
+ */
26
+ public function __construct(
27
+ StreamInterface $stream,
28
+ StreamInterface $target = null
29
+ ) {
30
+ $this->remoteStream = $stream;
31
+ $this->stream = $target ?: new Stream(fopen('php://temp', 'r+'));
32
+ }
33
+
34
+ public function getSize()
35
+ {
36
+ return max($this->stream->getSize(), $this->remoteStream->getSize());
37
+ }
38
+
39
+ public function rewind()
40
+ {
41
+ $this->seek(0);
42
+ }
43
+
44
+ public function seek($offset, $whence = SEEK_SET)
45
+ {
46
+ if ($whence == SEEK_SET) {
47
+ $byte = $offset;
48
+ } elseif ($whence == SEEK_CUR) {
49
+ $byte = $offset + $this->tell();
50
+ } elseif ($whence == SEEK_END) {
51
+ $size = $this->remoteStream->getSize();
52
+ if ($size === null) {
53
+ $size = $this->cacheEntireStream();
54
+ }
55
+ $byte = $size + $offset;
56
+ } else {
57
+ throw new \InvalidArgumentException('Invalid whence');
58
+ }
59
+
60
+ $diff = $byte - $this->stream->getSize();
61
+
62
+ if ($diff > 0) {
63
+ // Read the remoteStream until we have read in at least the amount
64
+ // of bytes requested, or we reach the end of the file.
65
+ while ($diff > 0 && !$this->remoteStream->eof()) {
66
+ $this->read($diff);
67
+ $diff = $byte - $this->stream->getSize();
68
+ }
69
+ } else {
70
+ // We can just do a normal seek since we've already seen this byte.
71
+ $this->stream->seek($byte);
72
+ }
73
+ }
74
+
75
+ public function read($length)
76
+ {
77
+ // Perform a regular read on any previously read data from the buffer
78
+ $data = $this->stream->read($length);
79
+ $remaining = $length - strlen($data);
80
+
81
+ // More data was requested so read from the remote stream
82
+ if ($remaining) {
83
+ // If data was written to the buffer in a position that would have
84
+ // been filled from the remote stream, then we must skip bytes on
85
+ // the remote stream to emulate overwriting bytes from that
86
+ // position. This mimics the behavior of other PHP stream wrappers.
87
+ $remoteData = $this->remoteStream->read(
88
+ $remaining + $this->skipReadBytes
89
+ );
90
+
91
+ if ($this->skipReadBytes) {
92
+ $len = strlen($remoteData);
93
+ $remoteData = substr($remoteData, $this->skipReadBytes);
94
+ $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
95
+ }
96
+
97
+ $data .= $remoteData;
98
+ $this->stream->write($remoteData);
99
+ }
100
+
101
+ return $data;
102
+ }
103
+
104
+ public function write($string)
105
+ {
106
+ // When appending to the end of the currently read stream, you'll want
107
+ // to skip bytes from being read from the remote stream to emulate
108
+ // other stream wrappers. Basically replacing bytes of data of a fixed
109
+ // length.
110
+ $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
111
+ if ($overflow > 0) {
112
+ $this->skipReadBytes += $overflow;
113
+ }
114
+
115
+ return $this->stream->write($string);
116
+ }
117
+
118
+ public function eof()
119
+ {
120
+ return $this->stream->eof() && $this->remoteStream->eof();
121
+ }
122
+
123
+ /**
124
+ * Close both the remote stream and buffer stream
125
+ */
126
+ public function close()
127
+ {
128
+ $this->remoteStream->close() && $this->stream->close();
129
+ }
130
+
131
+ private function cacheEntireStream()
132
+ {
133
+ $target = new FnStream(['write' => 'strlen']);
134
+ copy_to_stream($this, $target);
135
+
136
+ return $this->tell();
137
+ }
138
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/DroppingStream.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that begins dropping data once the size of the underlying
8
+ * stream becomes too full.
9
+ */
10
+ class DroppingStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ private $maxLength;
15
+
16
+ /**
17
+ * @param StreamInterface $stream Underlying stream to decorate.
18
+ * @param int $maxLength Maximum size before dropping data.
19
+ */
20
+ public function __construct(StreamInterface $stream, $maxLength)
21
+ {
22
+ $this->stream = $stream;
23
+ $this->maxLength = $maxLength;
24
+ }
25
+
26
+ public function write($string)
27
+ {
28
+ $diff = $this->maxLength - $this->stream->getSize();
29
+
30
+ // Begin returning 0 when the underlying stream is too large.
31
+ if ($diff <= 0) {
32
+ return 0;
33
+ }
34
+
35
+ // Write the stream or a subset of the stream if needed.
36
+ if (strlen($string) < $diff) {
37
+ return $this->stream->write($string);
38
+ }
39
+
40
+ return $this->stream->write(substr($string, 0, $diff));
41
+ }
42
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/FnStream.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Compose stream implementations based on a hash of functions.
8
+ *
9
+ * Allows for easy testing and extension of a provided stream without needing
10
+ * to create a concrete class for a simple extension point.
11
+ */
12
+ class FnStream implements StreamInterface
13
+ {
14
+ /** @var array */
15
+ private $methods;
16
+
17
+ /** @var array Methods that must be implemented in the given array */
18
+ private static $slots = ['__toString', 'close', 'detach', 'rewind',
19
+ 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
20
+ 'isReadable', 'read', 'getContents', 'getMetadata'];
21
+
22
+ /**
23
+ * @param array $methods Hash of method name to a callable.
24
+ */
25
+ public function __construct(array $methods)
26
+ {
27
+ $this->methods = $methods;
28
+
29
+ // Create the functions on the class
30
+ foreach ($methods as $name => $fn) {
31
+ $this->{'_fn_' . $name} = $fn;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Lazily determine which methods are not implemented.
37
+ * @throws \BadMethodCallException
38
+ */
39
+ public function __get($name)
40
+ {
41
+ throw new \BadMethodCallException(str_replace('_fn_', '', $name)
42
+ . '() is not implemented in the FnStream');
43
+ }
44
+
45
+ /**
46
+ * The close method is called on the underlying stream only if possible.
47
+ */
48
+ public function __destruct()
49
+ {
50
+ if (isset($this->_fn_close)) {
51
+ call_user_func($this->_fn_close);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Adds custom functionality to an underlying stream by intercepting
57
+ * specific method calls.
58
+ *
59
+ * @param StreamInterface $stream Stream to decorate
60
+ * @param array $methods Hash of method name to a closure
61
+ *
62
+ * @return FnStream
63
+ */
64
+ public static function decorate(StreamInterface $stream, array $methods)
65
+ {
66
+ // If any of the required methods were not provided, then simply
67
+ // proxy to the decorated stream.
68
+ foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
69
+ $methods[$diff] = [$stream, $diff];
70
+ }
71
+
72
+ return new self($methods);
73
+ }
74
+
75
+ public function __toString()
76
+ {
77
+ return call_user_func($this->_fn___toString);
78
+ }
79
+
80
+ public function close()
81
+ {
82
+ return call_user_func($this->_fn_close);
83
+ }
84
+
85
+ public function detach()
86
+ {
87
+ return call_user_func($this->_fn_detach);
88
+ }
89
+
90
+ public function getSize()
91
+ {
92
+ return call_user_func($this->_fn_getSize);
93
+ }
94
+
95
+ public function tell()
96
+ {
97
+ return call_user_func($this->_fn_tell);
98
+ }
99
+
100
+ public function eof()
101
+ {
102
+ return call_user_func($this->_fn_eof);
103
+ }
104
+
105
+ public function isSeekable()
106
+ {
107
+ return call_user_func($this->_fn_isSeekable);
108
+ }
109
+
110
+ public function rewind()
111
+ {
112
+ call_user_func($this->_fn_rewind);
113
+ }
114
+
115
+ public function seek($offset, $whence = SEEK_SET)
116
+ {
117
+ call_user_func($this->_fn_seek, $offset, $whence);
118
+ }
119
+
120
+ public function isWritable()
121
+ {
122
+ return call_user_func($this->_fn_isWritable);
123
+ }
124
+
125
+ public function write($string)
126
+ {
127
+ return call_user_func($this->_fn_write, $string);
128
+ }
129
+
130
+ public function isReadable()
131
+ {
132
+ return call_user_func($this->_fn_isReadable);
133
+ }
134
+
135
+ public function read($length)
136
+ {
137
+ return call_user_func($this->_fn_read, $length);
138
+ }
139
+
140
+ public function getContents()
141
+ {
142
+ return call_user_func($this->_fn_getContents);
143
+ }
144
+
145
+ public function getMetadata($key = null)
146
+ {
147
+ return call_user_func($this->_fn_getMetadata, $key);
148
+ }
149
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/InflateStream.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
8
+ *
9
+ * This stream decorator skips the first 10 bytes of the given stream to remove
10
+ * the gzip header, converts the provided stream to a PHP stream resource,
11
+ * then appends the zlib.inflate filter. The stream is then converted back
12
+ * to a Guzzle stream resource to be used as a Guzzle stream.
13
+ *
14
+ * @link http://tools.ietf.org/html/rfc1952
15
+ * @link http://php.net/manual/en/filters.compression.php
16
+ */
17
+ class InflateStream implements StreamInterface
18
+ {
19
+ use StreamDecoratorTrait;
20
+
21
+ public function __construct(StreamInterface $stream)
22
+ {
23
+ // read the first 10 bytes, ie. gzip header
24
+ $header = $stream->read(10);
25
+ $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
26
+ // Skip the header, that is 10 + length of filename + 1 (nil) bytes
27
+ $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
28
+ $resource = StreamWrapper::getResource($stream);
29
+ stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
30
+ $this->stream = new Stream($resource);
31
+ }
32
+
33
+ /**
34
+ * @param StreamInterface $stream
35
+ * @param $header
36
+ * @return int
37
+ */
38
+ private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
39
+ {
40
+ $filename_header_length = 0;
41
+
42
+ if (substr(bin2hex($header), 6, 2) === '08') {
43
+ // we have a filename, read until nil
44
+ $filename_header_length = 1;
45
+ while ($stream->read(1) !== chr(0)) {
46
+ $filename_header_length++;
47
+ }
48
+ }
49
+
50
+ return $filename_header_length;
51
+ }
52
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/LazyOpenStream.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Lazily reads or writes to a file that is opened only after an IO operation
8
+ * take place on the stream.
9
+ */
10
+ class LazyOpenStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var string File to open */
15
+ private $filename;
16
+
17
+ /** @var string $mode */
18
+ private $mode;
19
+
20
+ /**
21
+ * @param string $filename File to lazily open
22
+ * @param string $mode fopen mode to use when opening the stream
23
+ */
24
+ public function __construct($filename, $mode)
25
+ {
26
+ $this->filename = $filename;
27
+ $this->mode = $mode;
28
+ }
29
+
30
+ /**
31
+ * Creates the underlying stream lazily when required.
32
+ *
33
+ * @return StreamInterface
34
+ */
35
+ protected function createStream()
36
+ {
37
+ return stream_for(try_fopen($this->filename, $this->mode));
38
+ }
39
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/LimitStream.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+
7
+ /**
8
+ * Decorator used to return only a subset of a stream
9
+ */
10
+ class LimitStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ /** @var int Offset to start reading from */
15
+ private $offset;
16
+
17
+ /** @var int Limit the number of bytes that can be read */
18
+ private $limit;
19
+
20
+ /**
21
+ * @param StreamInterface $stream Stream to wrap
22
+ * @param int $limit Total number of bytes to allow to be read
23
+ * from the stream. Pass -1 for no limit.
24
+ * @param int|null $offset Position to seek to before reading (only
25
+ * works on seekable streams).
26
+ */
27
+ public function __construct(
28
+ StreamInterface $stream,
29
+ $limit = -1,
30
+ $offset = 0
31
+ ) {
32
+ $this->stream = $stream;
33
+ $this->setLimit($limit);
34
+ $this->setOffset($offset);
35
+ }
36
+
37
+ public function eof()
38
+ {
39
+ // Always return true if the underlying stream is EOF
40
+ if ($this->stream->eof()) {
41
+ return true;
42
+ }
43
+
44
+ // No limit and the underlying stream is not at EOF
45
+ if ($this->limit == -1) {
46
+ return false;
47
+ }
48
+
49
+ return $this->stream->tell() >= $this->offset + $this->limit;
50
+ }
51
+
52
+ /**
53
+ * Returns the size of the limited subset of data
54
+ * {@inheritdoc}
55
+ */
56
+ public function getSize()
57
+ {
58
+ if (null === ($length = $this->stream->getSize())) {
59
+ return null;
60
+ } elseif ($this->limit == -1) {
61
+ return $length - $this->offset;
62
+ } else {
63
+ return min($this->limit, $length - $this->offset);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Allow for a bounded seek on the read limited stream
69
+ * {@inheritdoc}
70
+ */
71
+ public function seek($offset, $whence = SEEK_SET)
72
+ {
73
+ if ($whence !== SEEK_SET || $offset < 0) {
74
+ throw new \RuntimeException(sprintf(
75
+ 'Cannot seek to offset % with whence %s',
76
+ $offset,
77
+ $whence
78
+ ));
79
+ }
80
+
81
+ $offset += $this->offset;
82
+
83
+ if ($this->limit !== -1) {
84
+ if ($offset > $this->offset + $this->limit) {
85
+ $offset = $this->offset + $this->limit;
86
+ }
87
+ }
88
+
89
+ $this->stream->seek($offset);
90
+ }
91
+
92
+ /**
93
+ * Give a relative tell()
94
+ * {@inheritdoc}
95
+ */
96
+ public function tell()
97
+ {
98
+ return $this->stream->tell() - $this->offset;
99
+ }
100
+
101
+ /**
102
+ * Set the offset to start limiting from
103
+ *
104
+ * @param int $offset Offset to seek to and begin byte limiting from
105
+ *
106
+ * @throws \RuntimeException if the stream cannot be seeked.
107
+ */
108
+ public function setOffset($offset)
109
+ {
110
+ $current = $this->stream->tell();
111
+
112
+ if ($current !== $offset) {
113
+ // If the stream cannot seek to the offset position, then read to it
114
+ if ($this->stream->isSeekable()) {
115
+ $this->stream->seek($offset);
116
+ } elseif ($current > $offset) {
117
+ throw new \RuntimeException("Could not seek to stream offset $offset");
118
+ } else {
119
+ $this->stream->read($offset - $current);
120
+ }
121
+ }
122
+
123
+ $this->offset = $offset;
124
+ }
125
+
126
+ /**
127
+ * Set the limit of bytes that the decorator allows to be read from the
128
+ * stream.
129
+ *
130
+ * @param int $limit Number of bytes to allow to be read from the stream.
131
+ * Use -1 for no limit.
132
+ */
133
+ public function setLimit($limit)
134
+ {
135
+ $this->limit = $limit;
136
+ }
137
+
138
+ public function read($length)
139
+ {
140
+ if ($this->limit == -1) {
141
+ return $this->stream->read($length);
142
+ }
143
+
144
+ // Check if the current position is less than the total allowed
145
+ // bytes + original offset
146
+ $remaining = ($this->offset + $this->limit) - $this->stream->tell();
147
+ if ($remaining > 0) {
148
+ // Only return the amount of requested data, ensuring that the byte
149
+ // limit is not exceeded
150
+ return $this->stream->read(min($remaining, $length));
151
+ }
152
+
153
+ return '';
154
+ }
155
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/MessageTrait.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Trait implementing functionality common to requests and responses.
8
+ */
9
+ trait MessageTrait
10
+ {
11
+ /** @var array Map of all registered headers, as original name => array of values */
12
+ private $headers = [];
13
+
14
+ /** @var array Map of lowercase header name => original name at registration */
15
+ private $headerNames = [];
16
+
17
+ /** @var string */
18
+ private $protocol = '1.1';
19
+
20
+ /** @var StreamInterface */
21
+ private $stream;
22
+
23
+ public function getProtocolVersion()
24
+ {
25
+ return $this->protocol;
26
+ }
27
+
28
+ public function withProtocolVersion($version)
29
+ {
30
+ if ($this->protocol === $version) {
31
+ return $this;
32
+ }
33
+
34
+ $new = clone $this;
35
+ $new->protocol = $version;
36
+ return $new;
37
+ }
38
+
39
+ public function getHeaders()
40
+ {
41
+ return $this->headers;
42
+ }
43
+
44
+ public function hasHeader($header)
45
+ {
46
+ return isset($this->headerNames[strtolower($header)]);
47
+ }
48
+
49
+ public function getHeader($header)
50
+ {
51
+ $header = strtolower($header);
52
+
53
+ if (!isset($this->headerNames[$header])) {
54
+ return [];
55
+ }
56
+
57
+ $header = $this->headerNames[$header];
58
+
59
+ return $this->headers[$header];
60
+ }
61
+
62
+ public function getHeaderLine($header)
63
+ {
64
+ return implode(', ', $this->getHeader($header));
65
+ }
66
+
67
+ public function withHeader($header, $value)
68
+ {
69
+ if (!is_array($value)) {
70
+ $value = [$value];
71
+ }
72
+
73
+ $value = $this->trimHeaderValues($value);
74
+ $normalized = strtolower($header);
75
+
76
+ $new = clone $this;
77
+ if (isset($new->headerNames[$normalized])) {
78
+ unset($new->headers[$new->headerNames[$normalized]]);
79
+ }
80
+ $new->headerNames[$normalized] = $header;
81
+ $new->headers[$header] = $value;
82
+
83
+ return $new;
84
+ }
85
+
86
+ public function withAddedHeader($header, $value)
87
+ {
88
+ if (!is_array($value)) {
89
+ $value = [$value];
90
+ }
91
+
92
+ $value = $this->trimHeaderValues($value);
93
+ $normalized = strtolower($header);
94
+
95
+ $new = clone $this;
96
+ if (isset($new->headerNames[$normalized])) {
97
+ $header = $this->headerNames[$normalized];
98
+ $new->headers[$header] = array_merge($this->headers[$header], $value);
99
+ } else {
100
+ $new->headerNames[$normalized] = $header;
101
+ $new->headers[$header] = $value;
102
+ }
103
+
104
+ return $new;
105
+ }
106
+
107
+ public function withoutHeader($header)
108
+ {
109
+ $normalized = strtolower($header);
110
+
111
+ if (!isset($this->headerNames[$normalized])) {
112
+ return $this;
113
+ }
114
+
115
+ $header = $this->headerNames[$normalized];
116
+
117
+ $new = clone $this;
118
+ unset($new->headers[$header], $new->headerNames[$normalized]);
119
+
120
+ return $new;
121
+ }
122
+
123
+ public function getBody()
124
+ {
125
+ if (!$this->stream) {
126
+ $this->stream = stream_for('');
127
+ }
128
+
129
+ return $this->stream;
130
+ }
131
+
132
+ public function withBody(StreamInterface $body)
133
+ {
134
+ if ($body === $this->stream) {
135
+ return $this;
136
+ }
137
+
138
+ $new = clone $this;
139
+ $new->stream = $body;
140
+ return $new;
141
+ }
142
+
143
+ private function setHeaders(array $headers)
144
+ {
145
+ $this->headerNames = $this->headers = [];
146
+ foreach ($headers as $header => $value) {
147
+ if (!is_array($value)) {
148
+ $value = [$value];
149
+ }
150
+
151
+ $value = $this->trimHeaderValues($value);
152
+ $normalized = strtolower($header);
153
+ if (isset($this->headerNames[$normalized])) {
154
+ $header = $this->headerNames[$normalized];
155
+ $this->headers[$header] = array_merge($this->headers[$header], $value);
156
+ } else {
157
+ $this->headerNames[$normalized] = $header;
158
+ $this->headers[$header] = $value;
159
+ }
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Trims whitespace from the header values.
165
+ *
166
+ * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
167
+ *
168
+ * header-field = field-name ":" OWS field-value OWS
169
+ * OWS = *( SP / HTAB )
170
+ *
171
+ * @param string[] $values Header values
172
+ *
173
+ * @return string[] Trimmed header values
174
+ *
175
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
176
+ */
177
+ private function trimHeaderValues(array $values)
178
+ {
179
+ return array_map(function ($value) {
180
+ return trim($value, " \t");
181
+ }, $values);
182
+ }
183
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/MultipartStream.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream that when read returns bytes for a streaming multipart or
8
+ * multipart/form-data stream.
9
+ */
10
+ class MultipartStream implements StreamInterface
11
+ {
12
+ use StreamDecoratorTrait;
13
+
14
+ private $boundary;
15
+
16
+ /**
17
+ * @param array $elements Array of associative arrays, each containing a
18
+ * required "name" key mapping to the form field,
19
+ * name, a required "contents" key mapping to a
20
+ * StreamInterface/resource/string, an optional
21
+ * "headers" associative array of custom headers,
22
+ * and an optional "filename" key mapping to a
23
+ * string to send as the filename in the part.
24
+ * @param string $boundary You can optionally provide a specific boundary
25
+ *
26
+ * @throws \InvalidArgumentException
27
+ */
28
+ public function __construct(array $elements = [], $boundary = null)
29
+ {
30
+ $this->boundary = $boundary ?: uniqid();
31
+ $this->stream = $this->createStream($elements);
32
+ }
33
+
34
+ /**
35
+ * Get the boundary
36
+ *
37
+ * @return string
38
+ */
39
+ public function getBoundary()
40
+ {
41
+ return $this->boundary;
42
+ }
43
+
44
+ public function isWritable()
45
+ {
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Get the headers needed before transferring the content of a POST file
51
+ */
52
+ private function getHeaders(array $headers)
53
+ {
54
+ $str = '';
55
+ foreach ($headers as $key => $value) {
56
+ $str .= "{$key}: {$value}\r\n";
57
+ }
58
+
59
+ return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
60
+ }
61
+
62
+ /**
63
+ * Create the aggregate stream that will be used to upload the POST data
64
+ */
65
+ protected function createStream(array $elements)
66
+ {
67
+ $stream = new AppendStream();
68
+
69
+ foreach ($elements as $element) {
70
+ $this->addElement($stream, $element);
71
+ }
72
+
73
+ // Add the trailing boundary with CRLF
74
+ $stream->addStream(stream_for("--{$this->boundary}--\r\n"));
75
+
76
+ return $stream;
77
+ }
78
+
79
+ private function addElement(AppendStream $stream, array $element)
80
+ {
81
+ foreach (['contents', 'name'] as $key) {
82
+ if (!array_key_exists($key, $element)) {
83
+ throw new \InvalidArgumentException("A '{$key}' key is required");
84
+ }
85
+ }
86
+
87
+ $element['contents'] = stream_for($element['contents']);
88
+
89
+ if (empty($element['filename'])) {
90
+ $uri = $element['contents']->getMetadata('uri');
91
+ if (substr($uri, 0, 6) !== 'php://') {
92
+ $element['filename'] = $uri;
93
+ }
94
+ }
95
+
96
+ list($body, $headers) = $this->createElement(
97
+ $element['name'],
98
+ $element['contents'],
99
+ isset($element['filename']) ? $element['filename'] : null,
100
+ isset($element['headers']) ? $element['headers'] : []
101
+ );
102
+
103
+ $stream->addStream(stream_for($this->getHeaders($headers)));
104
+ $stream->addStream($body);
105
+ $stream->addStream(stream_for("\r\n"));
106
+ }
107
+
108
+ /**
109
+ * @return array
110
+ */
111
+ private function createElement($name, $stream, $filename, array $headers)
112
+ {
113
+ // Set a default content-disposition header if one was no provided
114
+ $disposition = $this->getHeader($headers, 'content-disposition');
115
+ if (!$disposition) {
116
+ $headers['Content-Disposition'] = ($filename === '0' || $filename)
117
+ ? sprintf('form-data; name="%s"; filename="%s"',
118
+ $name,
119
+ basename($filename))
120
+ : "form-data; name=\"{$name}\"";
121
+ }
122
+
123
+ // Set a default content-length header if one was no provided
124
+ $length = $this->getHeader($headers, 'content-length');
125
+ if (!$length) {
126
+ if ($length = $stream->getSize()) {
127
+ $headers['Content-Length'] = (string) $length;
128
+ }
129
+ }
130
+
131
+ // Set a default Content-Type if one was not supplied
132
+ $type = $this->getHeader($headers, 'content-type');
133
+ if (!$type && ($filename === '0' || $filename)) {
134
+ if ($type = mimetype_from_filename($filename)) {
135
+ $headers['Content-Type'] = $type;
136
+ }
137
+ }
138
+
139
+ return [$stream, $headers];
140
+ }
141
+
142
+ private function getHeader(array $headers, $key)
143
+ {
144
+ $lowercaseHeader = strtolower($key);
145
+ foreach ($headers as $k => $v) {
146
+ if (strtolower($k) === $lowercaseHeader) {
147
+ return $v;
148
+ }
149
+ }
150
+
151
+ return null;
152
+ }
153
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/NoSeekStream.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator that prevents a stream from being seeked
8
+ */
9
+ class NoSeekStream implements StreamInterface
10
+ {
11
+ use StreamDecoratorTrait;
12
+
13
+ public function seek($offset, $whence = SEEK_SET)
14
+ {
15
+ throw new \RuntimeException('Cannot seek a NoSeekStream');
16
+ }
17
+
18
+ public function isSeekable()
19
+ {
20
+ return false;
21
+ }
22
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/PumpStream.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Provides a read only stream that pumps data from a PHP callable.
8
+ *
9
+ * When invoking the provided callable, the PumpStream will pass the amount of
10
+ * data requested to read to the callable. The callable can choose to ignore
11
+ * this value and return fewer or more bytes than requested. Any extra data
12
+ * returned by the provided callable is buffered internally until drained using
13
+ * the read() function of the PumpStream. The provided callable MUST return
14
+ * false when there is no more data to read.
15
+ */
16
+ class PumpStream implements StreamInterface
17
+ {
18
+ /** @var callable */
19
+ private $source;
20
+
21
+ /** @var int */
22
+ private $size;
23
+
24
+ /** @var int */
25
+ private $tellPos = 0;
26
+
27
+ /** @var array */
28
+ private $metadata;
29
+
30
+ /** @var BufferStream */
31
+ private $buffer;
32
+
33
+ /**
34
+ * @param callable $source Source of the stream data. The callable MAY
35
+ * accept an integer argument used to control the
36
+ * amount of data to return. The callable MUST
37
+ * return a string when called, or false on error
38
+ * or EOF.
39
+ * @param array $options Stream options:
40
+ * - metadata: Hash of metadata to use with stream.
41
+ * - size: Size of the stream, if known.
42
+ */
43
+ public function __construct(callable $source, array $options = [])
44
+ {
45
+ $this->source = $source;
46
+ $this->size = isset($options['size']) ? $options['size'] : null;
47
+ $this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
48
+ $this->buffer = new BufferStream();
49
+ }
50
+
51
+ public function __toString()
52
+ {
53
+ try {
54
+ return copy_to_string($this);
55
+ } catch (\Exception $e) {
56
+ return '';
57
+ }
58
+ }
59
+
60
+ public function close()
61
+ {
62
+ $this->detach();
63
+ }
64
+
65
+ public function detach()
66
+ {
67
+ $this->tellPos = false;
68
+ $this->source = null;
69
+ }
70
+
71
+ public function getSize()
72
+ {
73
+ return $this->size;
74
+ }
75
+
76
+ public function tell()
77
+ {
78
+ return $this->tellPos;
79
+ }
80
+
81
+ public function eof()
82
+ {
83
+ return !$this->source;
84
+ }
85
+
86
+ public function isSeekable()
87
+ {
88
+ return false;
89
+ }
90
+
91
+ public function rewind()
92
+ {
93
+ $this->seek(0);
94
+ }
95
+
96
+ public function seek($offset, $whence = SEEK_SET)
97
+ {
98
+ throw new \RuntimeException('Cannot seek a PumpStream');
99
+ }
100
+
101
+ public function isWritable()
102
+ {
103
+ return false;
104
+ }
105
+
106
+ public function write($string)
107
+ {
108
+ throw new \RuntimeException('Cannot write to a PumpStream');
109
+ }
110
+
111
+ public function isReadable()
112
+ {
113
+ return true;
114
+ }
115
+
116
+ public function read($length)
117
+ {
118
+ $data = $this->buffer->read($length);
119
+ $readLen = strlen($data);
120
+ $this->tellPos += $readLen;
121
+ $remaining = $length - $readLen;
122
+
123
+ if ($remaining) {
124
+ $this->pump($remaining);
125
+ $data .= $this->buffer->read($remaining);
126
+ $this->tellPos += strlen($data) - $readLen;
127
+ }
128
+
129
+ return $data;
130
+ }
131
+
132
+ public function getContents()
133
+ {
134
+ $result = '';
135
+ while (!$this->eof()) {
136
+ $result .= $this->read(1000000);
137
+ }
138
+
139
+ return $result;
140
+ }
141
+
142
+ public function getMetadata($key = null)
143
+ {
144
+ if (!$key) {
145
+ return $this->metadata;
146
+ }
147
+
148
+ return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
149
+ }
150
+
151
+ private function pump($length)
152
+ {
153
+ if ($this->source) {
154
+ do {
155
+ $data = call_user_func($this->source, $length);
156
+ if ($data === false || $data === null) {
157
+ $this->source = null;
158
+ return;
159
+ }
160
+ $this->buffer->write($data);
161
+ $length -= strlen($data);
162
+ } while ($length > 0);
163
+ }
164
+ }
165
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Request.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use InvalidArgumentException;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\StreamInterface;
7
+ use Psr\Http\Message\UriInterface;
8
+
9
+ /**
10
+ * PSR-7 request implementation.
11
+ */
12
+ class Request implements RequestInterface
13
+ {
14
+ use MessageTrait;
15
+
16
+ /** @var string */
17
+ private $method;
18
+
19
+ /** @var null|string */
20
+ private $requestTarget;
21
+
22
+ /** @var null|UriInterface */
23
+ private $uri;
24
+
25
+ /**
26
+ * @param string $method HTTP method
27
+ * @param string|UriInterface $uri URI
28
+ * @param array $headers Request headers
29
+ * @param string|null|resource|StreamInterface $body Request body
30
+ * @param string $version Protocol version
31
+ */
32
+ public function __construct(
33
+ $method,
34
+ $uri,
35
+ array $headers = [],
36
+ $body = null,
37
+ $version = '1.1'
38
+ ) {
39
+ if (!($uri instanceof UriInterface)) {
40
+ $uri = new Uri($uri);
41
+ }
42
+
43
+ $this->method = strtoupper($method);
44
+ $this->uri = $uri;
45
+ $this->setHeaders($headers);
46
+ $this->protocol = $version;
47
+
48
+ if (!$this->hasHeader('Host')) {
49
+ $this->updateHostFromUri();
50
+ }
51
+
52
+ if ($body !== '' && $body !== null) {
53
+ $this->stream = stream_for($body);
54
+ }
55
+ }
56
+
57
+ public function getRequestTarget()
58
+ {
59
+ if ($this->requestTarget !== null) {
60
+ return $this->requestTarget;
61
+ }
62
+
63
+ $target = $this->uri->getPath();
64
+ if ($target == '') {
65
+ $target = '/';
66
+ }
67
+ if ($this->uri->getQuery() != '') {
68
+ $target .= '?' . $this->uri->getQuery();
69
+ }
70
+
71
+ return $target;
72
+ }
73
+
74
+ public function withRequestTarget($requestTarget)
75
+ {
76
+ if (preg_match('#\s#', $requestTarget)) {
77
+ throw new InvalidArgumentException(
78
+ 'Invalid request target provided; cannot contain whitespace'
79
+ );
80
+ }
81
+
82
+ $new = clone $this;
83
+ $new->requestTarget = $requestTarget;
84
+ return $new;
85
+ }
86
+
87
+ public function getMethod()
88
+ {
89
+ return $this->method;
90
+ }
91
+
92
+ public function withMethod($method)
93
+ {
94
+ $new = clone $this;
95
+ $new->method = strtoupper($method);
96
+ return $new;
97
+ }
98
+
99
+ public function getUri()
100
+ {
101
+ return $this->uri;
102
+ }
103
+
104
+ public function withUri(UriInterface $uri, $preserveHost = false)
105
+ {
106
+ if ($uri === $this->uri) {
107
+ return $this;
108
+ }
109
+
110
+ $new = clone $this;
111
+ $new->uri = $uri;
112
+
113
+ if (!$preserveHost) {
114
+ $new->updateHostFromUri();
115
+ }
116
+
117
+ return $new;
118
+ }
119
+
120
+ private function updateHostFromUri()
121
+ {
122
+ $host = $this->uri->getHost();
123
+
124
+ if ($host == '') {
125
+ return;
126
+ }
127
+
128
+ if (($port = $this->uri->getPort()) !== null) {
129
+ $host .= ':' . $port;
130
+ }
131
+
132
+ if (isset($this->headerNames['host'])) {
133
+ $header = $this->headerNames['host'];
134
+ } else {
135
+ $header = 'Host';
136
+ $this->headerNames['host'] = 'Host';
137
+ }
138
+ // Ensure Host is the first header.
139
+ // See: http://tools.ietf.org/html/rfc7230#section-5.4
140
+ $this->headers = [$header => [$host]] + $this->headers;
141
+ }
142
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Response.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\ResponseInterface;
5
+
6
+ /**
7
+ * PSR-7 response implementation.
8
+ */
9
+ class Response implements ResponseInterface
10
+ {
11
+ use MessageTrait;
12
+
13
+ /** @var array Map of standard HTTP status code/reason phrases */
14
+ private static $phrases = [
15
+ 100 => 'Continue',
16
+ 101 => 'Switching Protocols',
17
+ 102 => 'Processing',
18
+ 200 => 'OK',
19
+ 201 => 'Created',
20
+ 202 => 'Accepted',
21
+ 203 => 'Non-Authoritative Information',
22
+ 204 => 'No Content',
23
+ 205 => 'Reset Content',
24
+ 206 => 'Partial Content',
25
+ 207 => 'Multi-status',
26
+ 208 => 'Already Reported',
27
+ 300 => 'Multiple Choices',
28
+ 301 => 'Moved Permanently',
29
+ 302 => 'Found',
30
+ 303 => 'See Other',
31
+ 304 => 'Not Modified',
32
+ 305 => 'Use Proxy',
33
+ 306 => 'Switch Proxy',
34
+ 307 => 'Temporary Redirect',
35
+ 400 => 'Bad Request',
36
+ 401 => 'Unauthorized',
37
+ 402 => 'Payment Required',
38
+ 403 => 'Forbidden',
39
+ 404 => 'Not Found',
40
+ 405 => 'Method Not Allowed',
41
+ 406 => 'Not Acceptable',
42
+ 407 => 'Proxy Authentication Required',
43
+ 408 => 'Request Time-out',
44
+ 409 => 'Conflict',
45
+ 410 => 'Gone',
46
+ 411 => 'Length Required',
47
+ 412 => 'Precondition Failed',
48
+ 413 => 'Request Entity Too Large',
49
+ 414 => 'Request-URI Too Large',
50
+ 415 => 'Unsupported Media Type',
51
+ 416 => 'Requested range not satisfiable',
52
+ 417 => 'Expectation Failed',
53
+ 418 => 'I\'m a teapot',
54
+ 422 => 'Unprocessable Entity',
55
+ 423 => 'Locked',
56
+ 424 => 'Failed Dependency',
57
+ 425 => 'Unordered Collection',
58
+ 426 => 'Upgrade Required',
59
+ 428 => 'Precondition Required',
60
+ 429 => 'Too Many Requests',
61
+ 431 => 'Request Header Fields Too Large',
62
+ 451 => 'Unavailable For Legal Reasons',
63
+ 500 => 'Internal Server Error',
64
+ 501 => 'Not Implemented',
65
+ 502 => 'Bad Gateway',
66
+ 503 => 'Service Unavailable',
67
+ 504 => 'Gateway Time-out',
68
+ 505 => 'HTTP Version not supported',
69
+ 506 => 'Variant Also Negotiates',
70
+ 507 => 'Insufficient Storage',
71
+ 508 => 'Loop Detected',
72
+ 511 => 'Network Authentication Required',
73
+ ];
74
+
75
+ /** @var string */
76
+ private $reasonPhrase = '';
77
+
78
+ /** @var int */
79
+ private $statusCode = 200;
80
+
81
+ /**
82
+ * @param int $status Status code
83
+ * @param array $headers Response headers
84
+ * @param string|null|resource|StreamInterface $body Response body
85
+ * @param string $version Protocol version
86
+ * @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
87
+ */
88
+ public function __construct(
89
+ $status = 200,
90
+ array $headers = [],
91
+ $body = null,
92
+ $version = '1.1',
93
+ $reason = null
94
+ ) {
95
+ $this->statusCode = (int) $status;
96
+
97
+ if ($body !== '' && $body !== null) {
98
+ $this->stream = stream_for($body);
99
+ }
100
+
101
+ $this->setHeaders($headers);
102
+ if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
103
+ $this->reasonPhrase = self::$phrases[$status];
104
+ } else {
105
+ $this->reasonPhrase = (string) $reason;
106
+ }
107
+
108
+ $this->protocol = $version;
109
+ }
110
+
111
+ public function getStatusCode()
112
+ {
113
+ return $this->statusCode;
114
+ }
115
+
116
+ public function getReasonPhrase()
117
+ {
118
+ return $this->reasonPhrase;
119
+ }
120
+
121
+ public function withStatus($code, $reasonPhrase = '')
122
+ {
123
+ $new = clone $this;
124
+ $new->statusCode = (int) $code;
125
+ if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
126
+ $reasonPhrase = self::$phrases[$new->statusCode];
127
+ }
128
+ $new->reasonPhrase = $reasonPhrase;
129
+ return $new;
130
+ }
131
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/ServerRequest.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Psr7;
4
+
5
+ use InvalidArgumentException;
6
+ use Psr\Http\Message\ServerRequestInterface;
7
+ use Psr\Http\Message\UriInterface;
8
+ use Psr\Http\Message\StreamInterface;
9
+ use Psr\Http\Message\UploadedFileInterface;
10
+
11
+ /**
12
+ * Server-side HTTP request
13
+ *
14
+ * Extends the Request definition to add methods for accessing incoming data,
15
+ * specifically server parameters, cookies, matched path parameters, query
16
+ * string arguments, body parameters, and upload file information.
17
+ *
18
+ * "Attributes" are discovered via decomposing the request (and usually
19
+ * specifically the URI path), and typically will be injected by the application.
20
+ *
21
+ * Requests are considered immutable; all methods that might change state are
22
+ * implemented such that they retain the internal state of the current
23
+ * message and return a new instance that contains the changed state.
24
+ */
25
+ class ServerRequest extends Request implements ServerRequestInterface
26
+ {
27
+ /**
28
+ * @var array
29
+ */
30
+ private $attributes = [];
31
+
32
+ /**
33
+ * @var array
34
+ */
35
+ private $cookieParams = [];
36
+
37
+ /**
38
+ * @var null|array|object
39
+ */
40
+ private $parsedBody;
41
+
42
+ /**
43
+ * @var array
44
+ */
45
+ private $queryParams = [];
46
+
47
+ /**
48
+ * @var array
49
+ */
50
+ private $serverParams;
51
+
52
+ /**
53
+ * @var array
54
+ */
55
+ private $uploadedFiles = [];
56
+
57
+ /**
58
+ * @param string $method HTTP method
59
+ * @param string|UriInterface $uri URI
60
+ * @param array $headers Request headers
61
+ * @param string|null|resource|StreamInterface $body Request body
62
+ * @param string $version Protocol version
63
+ * @param array $serverParams Typically the $_SERVER superglobal
64
+ */
65
+ public function __construct(
66
+ $method,
67
+ $uri,
68
+ array $headers = [],
69
+ $body = null,
70
+ $version = '1.1',
71
+ array $serverParams = []
72
+ ) {
73
+ $this->serverParams = $serverParams;
74
+
75
+ parent::__construct($method, $uri, $headers, $body, $version);
76
+ }
77
+
78
+ /**
79
+ * Return an UploadedFile instance array.
80
+ *
81
+ * @param array $files A array which respect $_FILES structure
82
+ * @throws InvalidArgumentException for unrecognized values
83
+ * @return array
84
+ */
85
+ public static function normalizeFiles(array $files)
86
+ {
87
+ $normalized = [];
88
+
89
+ foreach ($files as $key => $value) {
90
+ if ($value instanceof UploadedFileInterface) {
91
+ $normalized[$key] = $value;
92
+ } elseif (is_array($value) && isset($value['tmp_name'])) {
93
+ $normalized[$key] = self::createUploadedFileFromSpec($value);
94
+ } elseif (is_array($value)) {
95
+ $normalized[$key] = self::normalizeFiles($value);
96
+ continue;
97
+ } else {
98
+ throw new InvalidArgumentException('Invalid value in files specification');
99
+ }
100
+ }
101
+
102
+ return $normalized;
103
+ }
104
+
105
+ /**
106
+ * Create and return an UploadedFile instance from a $_FILES specification.
107
+ *
108
+ * If the specification represents an array of values, this method will
109
+ * delegate to normalizeNestedFileSpec() and return that return value.
110
+ *
111
+ * @param array $value $_FILES struct
112
+ * @return array|UploadedFileInterface
113
+ */
114
+ private static function createUploadedFileFromSpec(array $value)
115
+ {
116
+ if (is_array($value['tmp_name'])) {
117
+ return self::normalizeNestedFileSpec($value);
118
+ }
119
+
120
+ return new UploadedFile(
121
+ $value['tmp_name'],
122
+ (int) $value['size'],
123
+ (int) $value['error'],
124
+ $value['name'],
125
+ $value['type']
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Normalize an array of file specifications.
131
+ *
132
+ * Loops through all nested files and returns a normalized array of
133
+ * UploadedFileInterface instances.
134
+ *
135
+ * @param array $files
136
+ * @return UploadedFileInterface[]
137
+ */
138
+ private static function normalizeNestedFileSpec(array $files = [])
139
+ {
140
+ $normalizedFiles = [];
141
+
142
+ foreach (array_keys($files['tmp_name']) as $key) {
143
+ $spec = [
144
+ 'tmp_name' => $files['tmp_name'][$key],
145
+ 'size' => $files['size'][$key],
146
+ 'error' => $files['error'][$key],
147
+ 'name' => $files['name'][$key],
148
+ 'type' => $files['type'][$key],
149
+ ];
150
+ $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
151
+ }
152
+
153
+ return $normalizedFiles;
154
+ }
155
+
156
+ /**
157
+ * Return a ServerRequest populated with superglobals:
158
+ * $_GET
159
+ * $_POST
160
+ * $_COOKIE
161
+ * $_FILES
162
+ * $_SERVER
163
+ *
164
+ * @return ServerRequestInterface
165
+ */
166
+ public static function fromGlobals()
167
+ {
168
+ $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
169
+ $headers = function_exists('getallheaders') ? getallheaders() : [];
170
+ $uri = self::getUriFromGlobals();
171
+ $body = new LazyOpenStream('php://input', 'r+');
172
+ $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
173
+
174
+ $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
175
+
176
+ return $serverRequest
177
+ ->withCookieParams($_COOKIE)
178
+ ->withQueryParams($_GET)
179
+ ->withParsedBody($_POST)
180
+ ->withUploadedFiles(self::normalizeFiles($_FILES));
181
+ }
182
+
183
+ /**
184
+ * Get a Uri populated with values from $_SERVER.
185
+ *
186
+ * @return UriInterface
187
+ */
188
+ public static function getUriFromGlobals() {
189
+ $uri = new Uri('');
190
+
191
+ if (isset($_SERVER['HTTPS'])) {
192
+ $uri = $uri->withScheme($_SERVER['HTTPS'] == 'on' ? 'https' : 'http');
193
+ }
194
+
195
+ if (isset($_SERVER['HTTP_HOST'])) {
196
+ $uri = $uri->withHost($_SERVER['HTTP_HOST']);
197
+ } elseif (isset($_SERVER['SERVER_NAME'])) {
198
+ $uri = $uri->withHost($_SERVER['SERVER_NAME']);
199
+ }
200
+
201
+ if (isset($_SERVER['SERVER_PORT'])) {
202
+ $uri = $uri->withPort($_SERVER['SERVER_PORT']);
203
+ }
204
+
205
+ if (isset($_SERVER['REQUEST_URI'])) {
206
+ $uri = $uri->withPath(current(explode('?', $_SERVER['REQUEST_URI'])));
207
+ }
208
+
209
+ if (isset($_SERVER['QUERY_STRING'])) {
210
+ $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
211
+ }
212
+
213
+ return $uri;
214
+ }
215
+
216
+
217
+ /**
218
+ * {@inheritdoc}
219
+ */
220
+ public function getServerParams()
221
+ {
222
+ return $this->serverParams;
223
+ }
224
+
225
+ /**
226
+ * {@inheritdoc}
227
+ */
228
+ public function getUploadedFiles()
229
+ {
230
+ return $this->uploadedFiles;
231
+ }
232
+
233
+ /**
234
+ * {@inheritdoc}
235
+ */
236
+ public function withUploadedFiles(array $uploadedFiles)
237
+ {
238
+ $new = clone $this;
239
+ $new->uploadedFiles = $uploadedFiles;
240
+
241
+ return $new;
242
+ }
243
+
244
+ /**
245
+ * {@inheritdoc}
246
+ */
247
+ public function getCookieParams()
248
+ {
249
+ return $this->cookieParams;
250
+ }
251
+
252
+ /**
253
+ * {@inheritdoc}
254
+ */
255
+ public function withCookieParams(array $cookies)
256
+ {
257
+ $new = clone $this;
258
+ $new->cookieParams = $cookies;
259
+
260
+ return $new;
261
+ }
262
+
263
+ /**
264
+ * {@inheritdoc}
265
+ */
266
+ public function getQueryParams()
267
+ {
268
+ return $this->queryParams;
269
+ }
270
+
271
+ /**
272
+ * {@inheritdoc}
273
+ */
274
+ public function withQueryParams(array $query)
275
+ {
276
+ $new = clone $this;
277
+ $new->queryParams = $query;
278
+
279
+ return $new;
280
+ }
281
+
282
+ /**
283
+ * {@inheritdoc}
284
+ */
285
+ public function getParsedBody()
286
+ {
287
+ return $this->parsedBody;
288
+ }
289
+
290
+ /**
291
+ * {@inheritdoc}
292
+ */
293
+ public function withParsedBody($data)
294
+ {
295
+ $new = clone $this;
296
+ $new->parsedBody = $data;
297
+
298
+ return $new;
299
+ }
300
+
301
+ /**
302
+ * {@inheritdoc}
303
+ */
304
+ public function getAttributes()
305
+ {
306
+ return $this->attributes;
307
+ }
308
+
309
+ /**
310
+ * {@inheritdoc}
311
+ */
312
+ public function getAttribute($attribute, $default = null)
313
+ {
314
+ if (false === array_key_exists($attribute, $this->attributes)) {
315
+ return $default;
316
+ }
317
+
318
+ return $this->attributes[$attribute];
319
+ }
320
+
321
+ /**
322
+ * {@inheritdoc}
323
+ */
324
+ public function withAttribute($attribute, $value)
325
+ {
326
+ $new = clone $this;
327
+ $new->attributes[$attribute] = $value;
328
+
329
+ return $new;
330
+ }
331
+
332
+ /**
333
+ * {@inheritdoc}
334
+ */
335
+ public function withoutAttribute($attribute)
336
+ {
337
+ if (false === array_key_exists($attribute, $this->attributes)) {
338
+ return $this;
339
+ }
340
+
341
+ $new = clone $this;
342
+ unset($new->attributes[$attribute]);
343
+
344
+ return $new;
345
+ }
346
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Stream.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * PHP stream implementation.
8
+ *
9
+ * @var $stream
10
+ */
11
+ class Stream implements StreamInterface
12
+ {
13
+ private $stream;
14
+ private $size;
15
+ private $seekable;
16
+ private $readable;
17
+ private $writable;
18
+ private $uri;
19
+ private $customMetadata;
20
+
21
+ /** @var array Hash of readable and writable stream types */
22
+ private static $readWriteHash = [
23
+ 'read' => [
24
+ 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true,
25
+ 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true,
26
+ 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true,
27
+ 'x+t' => true, 'c+t' => true, 'a+' => true
28
+ ],
29
+ 'write' => [
30
+ 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true,
31
+ 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true,
32
+ 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true,
33
+ 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true
34
+ ]
35
+ ];
36
+
37
+ /**
38
+ * This constructor accepts an associative array of options.
39
+ *
40
+ * - size: (int) If a read stream would otherwise have an indeterminate
41
+ * size, but the size is known due to foreknowledge, then you can
42
+ * provide that size, in bytes.
43
+ * - metadata: (array) Any additional metadata to return when the metadata
44
+ * of the stream is accessed.
45
+ *
46
+ * @param resource $stream Stream resource to wrap.
47
+ * @param array $options Associative array of options.
48
+ *
49
+ * @throws \InvalidArgumentException if the stream is not a stream resource
50
+ */
51
+ public function __construct($stream, $options = [])
52
+ {
53
+ if (!is_resource($stream)) {
54
+ throw new \InvalidArgumentException('Stream must be a resource');
55
+ }
56
+
57
+ if (isset($options['size'])) {
58
+ $this->size = $options['size'];
59
+ }
60
+
61
+ $this->customMetadata = isset($options['metadata'])
62
+ ? $options['metadata']
63
+ : [];
64
+
65
+ $this->stream = $stream;
66
+ $meta = stream_get_meta_data($this->stream);
67
+ $this->seekable = $meta['seekable'];
68
+ $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]);
69
+ $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]);
70
+ $this->uri = $this->getMetadata('uri');
71
+ }
72
+
73
+ public function __get($name)
74
+ {
75
+ if ($name == 'stream') {
76
+ throw new \RuntimeException('The stream is detached');
77
+ }
78
+
79
+ throw new \BadMethodCallException('No value for ' . $name);
80
+ }
81
+
82
+ /**
83
+ * Closes the stream when the destructed
84
+ */
85
+ public function __destruct()
86
+ {
87
+ $this->close();
88
+ }
89
+
90
+ public function __toString()
91
+ {
92
+ try {
93
+ $this->seek(0);
94
+ return (string) stream_get_contents($this->stream);
95
+ } catch (\Exception $e) {
96
+ return '';
97
+ }
98
+ }
99
+
100
+ public function getContents()
101
+ {
102
+ $contents = stream_get_contents($this->stream);
103
+
104
+ if ($contents === false) {
105
+ throw new \RuntimeException('Unable to read stream contents');
106
+ }
107
+
108
+ return $contents;
109
+ }
110
+
111
+ public function close()
112
+ {
113
+ if (isset($this->stream)) {
114
+ if (is_resource($this->stream)) {
115
+ fclose($this->stream);
116
+ }
117
+ $this->detach();
118
+ }
119
+ }
120
+
121
+ public function detach()
122
+ {
123
+ if (!isset($this->stream)) {
124
+ return null;
125
+ }
126
+
127
+ $result = $this->stream;
128
+ unset($this->stream);
129
+ $this->size = $this->uri = null;
130
+ $this->readable = $this->writable = $this->seekable = false;
131
+
132
+ return $result;
133
+ }
134
+
135
+ public function getSize()
136
+ {
137
+ if ($this->size !== null) {
138
+ return $this->size;
139
+ }
140
+
141
+ if (!isset($this->stream)) {
142
+ return null;
143
+ }
144
+
145
+ // Clear the stat cache if the stream has a URI
146
+ if ($this->uri) {
147
+ clearstatcache(true, $this->uri);
148
+ }
149
+
150
+ $stats = fstat($this->stream);
151
+ if (isset($stats['size'])) {
152
+ $this->size = $stats['size'];
153
+ return $this->size;
154
+ }
155
+
156
+ return null;
157
+ }
158
+
159
+ public function isReadable()
160
+ {
161
+ return $this->readable;
162
+ }
163
+
164
+ public function isWritable()
165
+ {
166
+ return $this->writable;
167
+ }
168
+
169
+ public function isSeekable()
170
+ {
171
+ return $this->seekable;
172
+ }
173
+
174
+ public function eof()
175
+ {
176
+ return !$this->stream || feof($this->stream);
177
+ }
178
+
179
+ public function tell()
180
+ {
181
+ $result = ftell($this->stream);
182
+
183
+ if ($result === false) {
184
+ throw new \RuntimeException('Unable to determine stream position');
185
+ }
186
+
187
+ return $result;
188
+ }
189
+
190
+ public function rewind()
191
+ {
192
+ $this->seek(0);
193
+ }
194
+
195
+ public function seek($offset, $whence = SEEK_SET)
196
+ {
197
+ if (!$this->seekable) {
198
+ throw new \RuntimeException('Stream is not seekable');
199
+ } elseif (fseek($this->stream, $offset, $whence) === -1) {
200
+ throw new \RuntimeException('Unable to seek to stream position '
201
+ . $offset . ' with whence ' . var_export($whence, true));
202
+ }
203
+ }
204
+
205
+ public function read($length)
206
+ {
207
+ if (!$this->readable) {
208
+ throw new \RuntimeException('Cannot read from non-readable stream');
209
+ }
210
+
211
+ return fread($this->stream, $length);
212
+ }
213
+
214
+ public function write($string)
215
+ {
216
+ if (!$this->writable) {
217
+ throw new \RuntimeException('Cannot write to a non-writable stream');
218
+ }
219
+
220
+ // We can't know the size after writing anything
221
+ $this->size = null;
222
+ $result = fwrite($this->stream, $string);
223
+
224
+ if ($result === false) {
225
+ throw new \RuntimeException('Unable to write to stream');
226
+ }
227
+
228
+ return $result;
229
+ }
230
+
231
+ public function getMetadata($key = null)
232
+ {
233
+ if (!isset($this->stream)) {
234
+ return $key ? null : [];
235
+ } elseif (!$key) {
236
+ return $this->customMetadata + stream_get_meta_data($this->stream);
237
+ } elseif (isset($this->customMetadata[$key])) {
238
+ return $this->customMetadata[$key];
239
+ }
240
+
241
+ $meta = stream_get_meta_data($this->stream);
242
+
243
+ return isset($meta[$key]) ? $meta[$key] : null;
244
+ }
245
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Stream decorator trait
8
+ * @property StreamInterface stream
9
+ */
10
+ trait StreamDecoratorTrait
11
+ {
12
+ /**
13
+ * @param StreamInterface $stream Stream to decorate
14
+ */
15
+ public function __construct(StreamInterface $stream)
16
+ {
17
+ $this->stream = $stream;
18
+ }
19
+
20
+ /**
21
+ * Magic method used to create a new stream if streams are not added in
22
+ * the constructor of a decorator (e.g., LazyOpenStream).
23
+ *
24
+ * @param string $name Name of the property (allows "stream" only).
25
+ *
26
+ * @return StreamInterface
27
+ */
28
+ public function __get($name)
29
+ {
30
+ if ($name == 'stream') {
31
+ $this->stream = $this->createStream();
32
+ return $this->stream;
33
+ }
34
+
35
+ throw new \UnexpectedValueException("$name not found on class");
36
+ }
37
+
38
+ public function __toString()
39
+ {
40
+ try {
41
+ if ($this->isSeekable()) {
42
+ $this->seek(0);
43
+ }
44
+ return $this->getContents();
45
+ } catch (\Exception $e) {
46
+ // Really, PHP? https://bugs.php.net/bug.php?id=53648
47
+ trigger_error('StreamDecorator::__toString exception: '
48
+ . (string) $e, E_USER_ERROR);
49
+ return '';
50
+ }
51
+ }
52
+
53
+ public function getContents()
54
+ {
55
+ return copy_to_string($this);
56
+ }
57
+
58
+ /**
59
+ * Allow decorators to implement custom methods
60
+ *
61
+ * @param string $method Missing method name
62
+ * @param array $args Method arguments
63
+ *
64
+ * @return mixed
65
+ */
66
+ public function __call($method, array $args)
67
+ {
68
+ $result = call_user_func_array([$this->stream, $method], $args);
69
+
70
+ // Always return the wrapped object if the result is a return $this
71
+ return $result === $this->stream ? $this : $result;
72
+ }
73
+
74
+ public function close()
75
+ {
76
+ $this->stream->close();
77
+ }
78
+
79
+ public function getMetadata($key = null)
80
+ {
81
+ return $this->stream->getMetadata($key);
82
+ }
83
+
84
+ public function detach()
85
+ {
86
+ return $this->stream->detach();
87
+ }
88
+
89
+ public function getSize()
90
+ {
91
+ return $this->stream->getSize();
92
+ }
93
+
94
+ public function eof()
95
+ {
96
+ return $this->stream->eof();
97
+ }
98
+
99
+ public function tell()
100
+ {
101
+ return $this->stream->tell();
102
+ }
103
+
104
+ public function isReadable()
105
+ {
106
+ return $this->stream->isReadable();
107
+ }
108
+
109
+ public function isWritable()
110
+ {
111
+ return $this->stream->isWritable();
112
+ }
113
+
114
+ public function isSeekable()
115
+ {
116
+ return $this->stream->isSeekable();
117
+ }
118
+
119
+ public function rewind()
120
+ {
121
+ $this->seek(0);
122
+ }
123
+
124
+ public function seek($offset, $whence = SEEK_SET)
125
+ {
126
+ $this->stream->seek($offset, $whence);
127
+ }
128
+
129
+ public function read($length)
130
+ {
131
+ return $this->stream->read($length);
132
+ }
133
+
134
+ public function write($string)
135
+ {
136
+ return $this->stream->write($string);
137
+ }
138
+
139
+ /**
140
+ * Implement in subclasses to dynamically create streams when requested.
141
+ *
142
+ * @return StreamInterface
143
+ * @throws \BadMethodCallException
144
+ */
145
+ protected function createStream()
146
+ {
147
+ throw new \BadMethodCallException('Not implemented');
148
+ }
149
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/StreamWrapper.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+
6
+ /**
7
+ * Converts Guzzle streams into PHP stream resources.
8
+ */
9
+ class StreamWrapper
10
+ {
11
+ /** @var resource */
12
+ public $context;
13
+
14
+ /** @var StreamInterface */
15
+ private $stream;
16
+
17
+ /** @var string r, r+, or w */
18
+ private $mode;
19
+
20
+ /**
21
+ * Returns a resource representing the stream.
22
+ *
23
+ * @param StreamInterface $stream The stream to get a resource for
24
+ *
25
+ * @return resource
26
+ * @throws \InvalidArgumentException if stream is not readable or writable
27
+ */
28
+ public static function getResource(StreamInterface $stream)
29
+ {
30
+ self::register();
31
+
32
+ if ($stream->isReadable()) {
33
+ $mode = $stream->isWritable() ? 'r+' : 'r';
34
+ } elseif ($stream->isWritable()) {
35
+ $mode = 'w';
36
+ } else {
37
+ throw new \InvalidArgumentException('The stream must be readable, '
38
+ . 'writable, or both.');
39
+ }
40
+
41
+ return fopen('guzzle://stream', $mode, null, stream_context_create([
42
+ 'guzzle' => ['stream' => $stream]
43
+ ]));
44
+ }
45
+
46
+ /**
47
+ * Registers the stream wrapper if needed
48
+ */
49
+ public static function register()
50
+ {
51
+ if (!in_array('guzzle', stream_get_wrappers())) {
52
+ stream_wrapper_register('guzzle', __CLASS__);
53
+ }
54
+ }
55
+
56
+ public function stream_open($path, $mode, $options, &$opened_path)
57
+ {
58
+ $options = stream_context_get_options($this->context);
59
+
60
+ if (!isset($options['guzzle']['stream'])) {
61
+ return false;
62
+ }
63
+
64
+ $this->mode = $mode;
65
+ $this->stream = $options['guzzle']['stream'];
66
+
67
+ return true;
68
+ }
69
+
70
+ public function stream_read($count)
71
+ {
72
+ return $this->stream->read($count);
73
+ }
74
+
75
+ public function stream_write($data)
76
+ {
77
+ return (int) $this->stream->write($data);
78
+ }
79
+
80
+ public function stream_tell()
81
+ {
82
+ return $this->stream->tell();
83
+ }
84
+
85
+ public function stream_eof()
86
+ {
87
+ return $this->stream->eof();
88
+ }
89
+
90
+ public function stream_seek($offset, $whence)
91
+ {
92
+ $this->stream->seek($offset, $whence);
93
+
94
+ return true;
95
+ }
96
+
97
+ public function stream_stat()
98
+ {
99
+ static $modeMap = [
100
+ 'r' => 33060,
101
+ 'r+' => 33206,
102
+ 'w' => 33188
103
+ ];
104
+
105
+ return [
106
+ 'dev' => 0,
107
+ 'ino' => 0,
108
+ 'mode' => $modeMap[$this->mode],
109
+ 'nlink' => 0,
110
+ 'uid' => 0,
111
+ 'gid' => 0,
112
+ 'rdev' => 0,
113
+ 'size' => $this->stream->getSize() ?: 0,
114
+ 'atime' => 0,
115
+ 'mtime' => 0,
116
+ 'ctime' => 0,
117
+ 'blksize' => 0,
118
+ 'blocks' => 0
119
+ ];
120
+ }
121
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/UploadedFile.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use InvalidArgumentException;
5
+ use Psr\Http\Message\StreamInterface;
6
+ use Psr\Http\Message\UploadedFileInterface;
7
+ use RuntimeException;
8
+
9
+ class UploadedFile implements UploadedFileInterface
10
+ {
11
+ /**
12
+ * @var int[]
13
+ */
14
+ private static $errors = [
15
+ UPLOAD_ERR_OK,
16
+ UPLOAD_ERR_INI_SIZE,
17
+ UPLOAD_ERR_FORM_SIZE,
18
+ UPLOAD_ERR_PARTIAL,
19
+ UPLOAD_ERR_NO_FILE,
20
+ UPLOAD_ERR_NO_TMP_DIR,
21
+ UPLOAD_ERR_CANT_WRITE,
22
+ UPLOAD_ERR_EXTENSION,
23
+ ];
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ private $clientFilename;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ private $clientMediaType;
34
+
35
+ /**
36
+ * @var int
37
+ */
38
+ private $error;
39
+
40
+ /**
41
+ * @var null|string
42
+ */
43
+ private $file;
44
+
45
+ /**
46
+ * @var bool
47
+ */
48
+ private $moved = false;
49
+
50
+ /**
51
+ * @var int
52
+ */
53
+ private $size;
54
+
55
+ /**
56
+ * @var StreamInterface|null
57
+ */
58
+ private $stream;
59
+
60
+ /**
61
+ * @param StreamInterface|string|resource $streamOrFile
62
+ * @param int $size
63
+ * @param int $errorStatus
64
+ * @param string|null $clientFilename
65
+ * @param string|null $clientMediaType
66
+ */
67
+ public function __construct(
68
+ $streamOrFile,
69
+ $size,
70
+ $errorStatus,
71
+ $clientFilename = null,
72
+ $clientMediaType = null
73
+ ) {
74
+ $this->setError($errorStatus);
75
+ $this->setSize($size);
76
+ $this->setClientFilename($clientFilename);
77
+ $this->setClientMediaType($clientMediaType);
78
+
79
+ if ($this->isOk()) {
80
+ $this->setStreamOrFile($streamOrFile);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Depending on the value set file or stream variable
86
+ *
87
+ * @param mixed $streamOrFile
88
+ * @throws InvalidArgumentException
89
+ */
90
+ private function setStreamOrFile($streamOrFile)
91
+ {
92
+ if (is_string($streamOrFile)) {
93
+ $this->file = $streamOrFile;
94
+ } elseif (is_resource($streamOrFile)) {
95
+ $this->stream = new Stream($streamOrFile);
96
+ } elseif ($streamOrFile instanceof StreamInterface) {
97
+ $this->stream = $streamOrFile;
98
+ } else {
99
+ throw new InvalidArgumentException(
100
+ 'Invalid stream or file provided for UploadedFile'
101
+ );
102
+ }
103
+ }
104
+
105
+ /**
106
+ * @param int $error
107
+ * @throws InvalidArgumentException
108
+ */
109
+ private function setError($error)
110
+ {
111
+ if (false === is_int($error)) {
112
+ throw new InvalidArgumentException(
113
+ 'Upload file error status must be an integer'
114
+ );
115
+ }
116
+
117
+ if (false === in_array($error, UploadedFile::$errors)) {
118
+ throw new InvalidArgumentException(
119
+ 'Invalid error status for UploadedFile'
120
+ );
121
+ }
122
+
123
+ $this->error = $error;
124
+ }
125
+
126
+ /**
127
+ * @param int $size
128
+ * @throws InvalidArgumentException
129
+ */
130
+ private function setSize($size)
131
+ {
132
+ if (false === is_int($size)) {
133
+ throw new InvalidArgumentException(
134
+ 'Upload file size must be an integer'
135
+ );
136
+ }
137
+
138
+ $this->size = $size;
139
+ }
140
+
141
+ /**
142
+ * @param mixed $param
143
+ * @return boolean
144
+ */
145
+ private function isStringOrNull($param)
146
+ {
147
+ return in_array(gettype($param), ['string', 'NULL']);
148
+ }
149
+
150
+ /**
151
+ * @param mixed $param
152
+ * @return boolean
153
+ */
154
+ private function isStringNotEmpty($param)
155
+ {
156
+ return is_string($param) && false === empty($param);
157
+ }
158
+
159
+ /**
160
+ * @param string|null $clientFilename
161
+ * @throws InvalidArgumentException
162
+ */
163
+ private function setClientFilename($clientFilename)
164
+ {
165
+ if (false === $this->isStringOrNull($clientFilename)) {
166
+ throw new InvalidArgumentException(
167
+ 'Upload file client filename must be a string or null'
168
+ );
169
+ }
170
+
171
+ $this->clientFilename = $clientFilename;
172
+ }
173
+
174
+ /**
175
+ * @param string|null $clientMediaType
176
+ * @throws InvalidArgumentException
177
+ */
178
+ private function setClientMediaType($clientMediaType)
179
+ {
180
+ if (false === $this->isStringOrNull($clientMediaType)) {
181
+ throw new InvalidArgumentException(
182
+ 'Upload file client media type must be a string or null'
183
+ );
184
+ }
185
+
186
+ $this->clientMediaType = $clientMediaType;
187
+ }
188
+
189
+ /**
190
+ * Return true if there is no upload error
191
+ *
192
+ * @return boolean
193
+ */
194
+ private function isOk()
195
+ {
196
+ return $this->error === UPLOAD_ERR_OK;
197
+ }
198
+
199
+ /**
200
+ * @return boolean
201
+ */
202
+ public function isMoved()
203
+ {
204
+ return $this->moved;
205
+ }
206
+
207
+ /**
208
+ * @throws RuntimeException if is moved or not ok
209
+ */
210
+ private function validateActive()
211
+ {
212
+ if (false === $this->isOk()) {
213
+ throw new RuntimeException('Cannot retrieve stream due to upload error');
214
+ }
215
+
216
+ if ($this->isMoved()) {
217
+ throw new RuntimeException('Cannot retrieve stream after it has already been moved');
218
+ }
219
+ }
220
+
221
+ /**
222
+ * {@inheritdoc}
223
+ * @throws RuntimeException if the upload was not successful.
224
+ */
225
+ public function getStream()
226
+ {
227
+ $this->validateActive();
228
+
229
+ if ($this->stream instanceof StreamInterface) {
230
+ return $this->stream;
231
+ }
232
+
233
+ return new LazyOpenStream($this->file, 'r+');
234
+ }
235
+
236
+ /**
237
+ * {@inheritdoc}
238
+ *
239
+ * @see http://php.net/is_uploaded_file
240
+ * @see http://php.net/move_uploaded_file
241
+ * @param string $targetPath Path to which to move the uploaded file.
242
+ * @throws RuntimeException if the upload was not successful.
243
+ * @throws InvalidArgumentException if the $path specified is invalid.
244
+ * @throws RuntimeException on any error during the move operation, or on
245
+ * the second or subsequent call to the method.
246
+ */
247
+ public function moveTo($targetPath)
248
+ {
249
+ $this->validateActive();
250
+
251
+ if (false === $this->isStringNotEmpty($targetPath)) {
252
+ throw new InvalidArgumentException(
253
+ 'Invalid path provided for move operation; must be a non-empty string'
254
+ );
255
+ }
256
+
257
+ if ($this->file) {
258
+ $this->moved = php_sapi_name() == 'cli'
259
+ ? rename($this->file, $targetPath)
260
+ : move_uploaded_file($this->file, $targetPath);
261
+ } else {
262
+ copy_to_stream(
263
+ $this->getStream(),
264
+ new LazyOpenStream($targetPath, 'w')
265
+ );
266
+
267
+ $this->moved = true;
268
+ }
269
+
270
+ if (false === $this->moved) {
271
+ throw new RuntimeException(
272
+ sprintf('Uploaded file could not be moved to %s', $targetPath)
273
+ );
274
+ }
275
+ }
276
+
277
+ /**
278
+ * {@inheritdoc}
279
+ *
280
+ * @return int|null The file size in bytes or null if unknown.
281
+ */
282
+ public function getSize()
283
+ {
284
+ return $this->size;
285
+ }
286
+
287
+ /**
288
+ * {@inheritdoc}
289
+ *
290
+ * @see http://php.net/manual/en/features.file-upload.errors.php
291
+ * @return int One of PHP's UPLOAD_ERR_XXX constants.
292
+ */
293
+ public function getError()
294
+ {
295
+ return $this->error;
296
+ }
297
+
298
+ /**
299
+ * {@inheritdoc}
300
+ *
301
+ * @return string|null The filename sent by the client or null if none
302
+ * was provided.
303
+ */
304
+ public function getClientFilename()
305
+ {
306
+ return $this->clientFilename;
307
+ }
308
+
309
+ /**
310
+ * {@inheritdoc}
311
+ */
312
+ public function getClientMediaType()
313
+ {
314
+ return $this->clientMediaType;
315
+ }
316
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/Uri.php ADDED
@@ -0,0 +1,602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\UriInterface;
5
+
6
+ /**
7
+ * PSR-7 URI implementation.
8
+ *
9
+ * @author Michael Dowling
10
+ * @author Tobias Schultze
11
+ * @author Matthew Weier O'Phinney
12
+ */
13
+ class Uri implements UriInterface
14
+ {
15
+ private static $schemes = [
16
+ 'http' => 80,
17
+ 'https' => 443,
18
+ ];
19
+
20
+ private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
21
+ private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
22
+ private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
23
+
24
+ /** @var string Uri scheme. */
25
+ private $scheme = '';
26
+
27
+ /** @var string Uri user info. */
28
+ private $userInfo = '';
29
+
30
+ /** @var string Uri host. */
31
+ private $host = '';
32
+
33
+ /** @var int|null Uri port. */
34
+ private $port;
35
+
36
+ /** @var string Uri path. */
37
+ private $path = '';
38
+
39
+ /** @var string Uri query string. */
40
+ private $query = '';
41
+
42
+ /** @var string Uri fragment. */
43
+ private $fragment = '';
44
+
45
+ /**
46
+ * @param string $uri URI to parse
47
+ */
48
+ public function __construct($uri = '')
49
+ {
50
+ if ($uri != '') {
51
+ $parts = parse_url($uri);
52
+ if ($parts === false) {
53
+ throw new \InvalidArgumentException("Unable to parse URI: $uri");
54
+ }
55
+ $this->applyParts($parts);
56
+ }
57
+ }
58
+
59
+ public function __toString()
60
+ {
61
+ return self::createUriString(
62
+ $this->scheme,
63
+ $this->getAuthority(),
64
+ $this->path,
65
+ $this->query,
66
+ $this->fragment
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Removes dot segments from a path and returns the new path.
72
+ *
73
+ * @param string $path
74
+ *
75
+ * @return string
76
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.4
77
+ */
78
+ public static function removeDotSegments($path)
79
+ {
80
+ static $noopPaths = ['' => true, '/' => true, '*' => true];
81
+ static $ignoreSegments = ['.' => true, '..' => true];
82
+
83
+ if (isset($noopPaths[$path])) {
84
+ return $path;
85
+ }
86
+
87
+ $results = [];
88
+ $segments = explode('/', $path);
89
+ foreach ($segments as $segment) {
90
+ if ($segment === '..') {
91
+ array_pop($results);
92
+ } elseif (!isset($ignoreSegments[$segment])) {
93
+ $results[] = $segment;
94
+ }
95
+ }
96
+
97
+ $newPath = implode('/', $results);
98
+ // Add the leading slash if necessary
99
+ if (substr($path, 0, 1) === '/' &&
100
+ substr($newPath, 0, 1) !== '/'
101
+ ) {
102
+ $newPath = '/' . $newPath;
103
+ }
104
+
105
+ // Add the trailing slash if necessary
106
+ if ($newPath !== '/' && isset($ignoreSegments[end($segments)])) {
107
+ $newPath .= '/';
108
+ }
109
+
110
+ return $newPath;
111
+ }
112
+
113
+ /**
114
+ * Resolve a base URI with a relative URI and return a new URI.
115
+ *
116
+ * @param UriInterface $base Base URI
117
+ * @param string|UriInterface $rel Relative URI
118
+ *
119
+ * @return UriInterface
120
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2
121
+ */
122
+ public static function resolve(UriInterface $base, $rel)
123
+ {
124
+ if (!($rel instanceof UriInterface)) {
125
+ $rel = new self($rel);
126
+ }
127
+
128
+ if ((string) $rel === '') {
129
+ // we can simply return the same base URI instance for this same-document reference
130
+ return $base;
131
+ }
132
+
133
+ if ($rel->getScheme() != '') {
134
+ return $rel->withPath(self::removeDotSegments($rel->getPath()));
135
+ }
136
+
137
+ if ($rel->getAuthority() != '') {
138
+ $targetAuthority = $rel->getAuthority();
139
+ $targetPath = self::removeDotSegments($rel->getPath());
140
+ $targetQuery = $rel->getQuery();
141
+ } else {
142
+ $targetAuthority = $base->getAuthority();
143
+ if ($rel->getPath() === '') {
144
+ $targetPath = $base->getPath();
145
+ $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
146
+ } else {
147
+ if ($rel->getPath()[0] === '/') {
148
+ $targetPath = $rel->getPath();
149
+ } else {
150
+ if ($targetAuthority != '' && $base->getPath() === '') {
151
+ $targetPath = '/' . $rel->getPath();
152
+ } else {
153
+ $lastSlashPos = strrpos($base->getPath(), '/');
154
+ if ($lastSlashPos === false) {
155
+ $targetPath = $rel->getPath();
156
+ } else {
157
+ $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
158
+ }
159
+ }
160
+ }
161
+ $targetPath = self::removeDotSegments($targetPath);
162
+ $targetQuery = $rel->getQuery();
163
+ }
164
+ }
165
+
166
+ return new self(self::createUriString(
167
+ $base->getScheme(),
168
+ $targetAuthority,
169
+ $targetPath,
170
+ $targetQuery,
171
+ $rel->getFragment()
172
+ ));
173
+ }
174
+
175
+ /**
176
+ * Create a new URI with a specific query string value removed.
177
+ *
178
+ * Any existing query string values that exactly match the provided key are
179
+ * removed.
180
+ *
181
+ * @param UriInterface $uri URI to use as a base.
182
+ * @param string $key Query string key to remove.
183
+ *
184
+ * @return UriInterface
185
+ */
186
+ public static function withoutQueryValue(UriInterface $uri, $key)
187
+ {
188
+ $current = $uri->getQuery();
189
+ if ($current == '') {
190
+ return $uri;
191
+ }
192
+
193
+ $decodedKey = rawurldecode($key);
194
+ $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) {
195
+ return rawurldecode(explode('=', $part)[0]) !== $decodedKey;
196
+ });
197
+
198
+ return $uri->withQuery(implode('&', $result));
199
+ }
200
+
201
+ /**
202
+ * Create a new URI with a specific query string value.
203
+ *
204
+ * Any existing query string values that exactly match the provided key are
205
+ * removed and replaced with the given key value pair.
206
+ *
207
+ * A value of null will set the query string key without a value, e.g. "key"
208
+ * instead of "key=value".
209
+ *
210
+ * @param UriInterface $uri URI to use as a base.
211
+ * @param string $key Key to set.
212
+ * @param string|null $value Value to set
213
+ *
214
+ * @return UriInterface
215
+ */
216
+ public static function withQueryValue(UriInterface $uri, $key, $value)
217
+ {
218
+ $current = $uri->getQuery();
219
+
220
+ if ($current == '') {
221
+ $result = [];
222
+ } else {
223
+ $decodedKey = rawurldecode($key);
224
+ $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) {
225
+ return rawurldecode(explode('=', $part)[0]) !== $decodedKey;
226
+ });
227
+ }
228
+
229
+ // Query string separators ("=", "&") within the key or value need to be encoded
230
+ // (while preventing double-encoding) before setting the query string. All other
231
+ // chars that need percent-encoding will be encoded by withQuery().
232
+ $key = strtr($key, self::$replaceQuery);
233
+
234
+ if ($value !== null) {
235
+ $result[] = $key . '=' . strtr($value, self::$replaceQuery);
236
+ } else {
237
+ $result[] = $key;
238
+ }
239
+
240
+ return $uri->withQuery(implode('&', $result));
241
+ }
242
+
243
+ /**
244
+ * Create a URI from a hash of parse_url parts.
245
+ *
246
+ * @param array $parts
247
+ *
248
+ * @return self
249
+ */
250
+ public static function fromParts(array $parts)
251
+ {
252
+ $uri = new self();
253
+ $uri->applyParts($parts);
254
+ return $uri;
255
+ }
256
+
257
+ public function getScheme()
258
+ {
259
+ return $this->scheme;
260
+ }
261
+
262
+ public function getAuthority()
263
+ {
264
+ if ($this->host == '') {
265
+ return '';
266
+ }
267
+
268
+ $authority = $this->host;
269
+ if ($this->userInfo != '') {
270
+ $authority = $this->userInfo . '@' . $authority;
271
+ }
272
+
273
+ if ($this->port !== null) {
274
+ $authority .= ':' . $this->port;
275
+ }
276
+
277
+ return $authority;
278
+ }
279
+
280
+ public function getUserInfo()
281
+ {
282
+ return $this->userInfo;
283
+ }
284
+
285
+ public function getHost()
286
+ {
287
+ return $this->host;
288
+ }
289
+
290
+ public function getPort()
291
+ {
292
+ return $this->port;
293
+ }
294
+
295
+ public function getPath()
296
+ {
297
+ return $this->path;
298
+ }
299
+
300
+ public function getQuery()
301
+ {
302
+ return $this->query;
303
+ }
304
+
305
+ public function getFragment()
306
+ {
307
+ return $this->fragment;
308
+ }
309
+
310
+ public function withScheme($scheme)
311
+ {
312
+ $scheme = $this->filterScheme($scheme);
313
+
314
+ if ($this->scheme === $scheme) {
315
+ return $this;
316
+ }
317
+
318
+ $new = clone $this;
319
+ $new->scheme = $scheme;
320
+ $new->port = $new->filterPort($new->port);
321
+ return $new;
322
+ }
323
+
324
+ public function withUserInfo($user, $password = null)
325
+ {
326
+ $info = $user;
327
+ if ($password != '') {
328
+ $info .= ':' . $password;
329
+ }
330
+
331
+ if ($this->userInfo === $info) {
332
+ return $this;
333
+ }
334
+
335
+ $new = clone $this;
336
+ $new->userInfo = $info;
337
+ return $new;
338
+ }
339
+
340
+ public function withHost($host)
341
+ {
342
+ $host = $this->filterHost($host);
343
+
344
+ if ($this->host === $host) {
345
+ return $this;
346
+ }
347
+
348
+ $new = clone $this;
349
+ $new->host = $host;
350
+ return $new;
351
+ }
352
+
353
+ public function withPort($port)
354
+ {
355
+ $port = $this->filterPort($port);
356
+
357
+ if ($this->port === $port) {
358
+ return $this;
359
+ }
360
+
361
+ $new = clone $this;
362
+ $new->port = $port;
363
+ return $new;
364
+ }
365
+
366
+ public function withPath($path)
367
+ {
368
+ $path = $this->filterPath($path);
369
+
370
+ if ($this->path === $path) {
371
+ return $this;
372
+ }
373
+
374
+ $new = clone $this;
375
+ $new->path = $path;
376
+ return $new;
377
+ }
378
+
379
+ public function withQuery($query)
380
+ {
381
+ $query = $this->filterQueryAndFragment($query);
382
+
383
+ if ($this->query === $query) {
384
+ return $this;
385
+ }
386
+
387
+ $new = clone $this;
388
+ $new->query = $query;
389
+ return $new;
390
+ }
391
+
392
+ public function withFragment($fragment)
393
+ {
394
+ $fragment = $this->filterQueryAndFragment($fragment);
395
+
396
+ if ($this->fragment === $fragment) {
397
+ return $this;
398
+ }
399
+
400
+ $new = clone $this;
401
+ $new->fragment = $fragment;
402
+ return $new;
403
+ }
404
+
405
+ /**
406
+ * Apply parse_url parts to a URI.
407
+ *
408
+ * @param array $parts Array of parse_url parts to apply.
409
+ */
410
+ private function applyParts(array $parts)
411
+ {
412
+ $this->scheme = isset($parts['scheme'])
413
+ ? $this->filterScheme($parts['scheme'])
414
+ : '';
415
+ $this->userInfo = isset($parts['user']) ? $parts['user'] : '';
416
+ $this->host = isset($parts['host'])
417
+ ? $this->filterHost($parts['host'])
418
+ : '';
419
+ $this->port = isset($parts['port'])
420
+ ? $this->filterPort($parts['port'])
421
+ : null;
422
+ $this->path = isset($parts['path'])
423
+ ? $this->filterPath($parts['path'])
424
+ : '';
425
+ $this->query = isset($parts['query'])
426
+ ? $this->filterQueryAndFragment($parts['query'])
427
+ : '';
428
+ $this->fragment = isset($parts['fragment'])
429
+ ? $this->filterQueryAndFragment($parts['fragment'])
430
+ : '';
431
+ if (isset($parts['pass'])) {
432
+ $this->userInfo .= ':' . $parts['pass'];
433
+ }
434
+ }
435
+
436
+ /**
437
+ * Create a URI string from its various parts
438
+ *
439
+ * @param string $scheme
440
+ * @param string $authority
441
+ * @param string $path
442
+ * @param string $query
443
+ * @param string $fragment
444
+ * @return string
445
+ */
446
+ private static function createUriString($scheme, $authority, $path, $query, $fragment)
447
+ {
448
+ $uri = '';
449
+
450
+ if ($scheme != '') {
451
+ $uri .= $scheme . ':';
452
+ }
453
+
454
+ if ($authority != '') {
455
+ $uri .= '//' . $authority;
456
+ }
457
+
458
+ if ($path != '') {
459
+ if ($path[0] !== '/') {
460
+ if ($authority != '') {
461
+ // If the path is rootless and an authority is present, the path MUST be prefixed by "/"
462
+ $path = '/' . $path;
463
+ }
464
+ } elseif (isset($path[1]) && $path[1] === '/') {
465
+ if ($authority == '') {
466
+ // If the path is starting with more than one "/" and no authority is present, the
467
+ // starting slashes MUST be reduced to one.
468
+ $path = '/' . ltrim($path, '/');
469
+ }
470
+ }
471
+
472
+ $uri .= $path;
473
+ }
474
+
475
+ if ($query != '') {
476
+ $uri .= '?' . $query;
477
+ }
478
+
479
+ if ($fragment != '') {
480
+ $uri .= '#' . $fragment;
481
+ }
482
+
483
+ return $uri;
484
+ }
485
+
486
+ /**
487
+ * Is a given port non-standard for the current scheme?
488
+ *
489
+ * @param string $scheme
490
+ * @param int $port
491
+ *
492
+ * @return bool
493
+ */
494
+ private static function isNonStandardPort($scheme, $port)
495
+ {
496
+ return !isset(self::$schemes[$scheme]) || $port !== self::$schemes[$scheme];
497
+ }
498
+
499
+ /**
500
+ * @param string $scheme
501
+ *
502
+ * @return string
503
+ *
504
+ * @throws \InvalidArgumentException If the scheme is invalid.
505
+ */
506
+ private function filterScheme($scheme)
507
+ {
508
+ if (!is_string($scheme)) {
509
+ throw new \InvalidArgumentException('Scheme must be a string');
510
+ }
511
+
512
+ return strtolower($scheme);
513
+ }
514
+
515
+ /**
516
+ * @param string $host
517
+ *
518
+ * @return string
519
+ *
520
+ * @throws \InvalidArgumentException If the host is invalid.
521
+ */
522
+ private function filterHost($host)
523
+ {
524
+ if (!is_string($host)) {
525
+ throw new \InvalidArgumentException('Host must be a string');
526
+ }
527
+
528
+ return strtolower($host);
529
+ }
530
+
531
+ /**
532
+ * @param int|null $port
533
+ *
534
+ * @return int|null
535
+ *
536
+ * @throws \InvalidArgumentException If the port is invalid.
537
+ */
538
+ private function filterPort($port)
539
+ {
540
+ if ($port === null) {
541
+ return null;
542
+ }
543
+
544
+ $port = (int) $port;
545
+ if (1 > $port || 0xffff < $port) {
546
+ throw new \InvalidArgumentException(
547
+ sprintf('Invalid port: %d. Must be between 1 and 65535', $port)
548
+ );
549
+ }
550
+
551
+ return self::isNonStandardPort($this->scheme, $port) ? $port : null;
552
+ }
553
+
554
+ /**
555
+ * Filters the path of a URI
556
+ *
557
+ * @param string $path
558
+ *
559
+ * @return string
560
+ *
561
+ * @throws \InvalidArgumentException If the path is invalid.
562
+ */
563
+ private function filterPath($path)
564
+ {
565
+ if (!is_string($path)) {
566
+ throw new \InvalidArgumentException('Path must be a string');
567
+ }
568
+
569
+ return preg_replace_callback(
570
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
571
+ [$this, 'rawurlencodeMatchZero'],
572
+ $path
573
+ );
574
+ }
575
+
576
+ /**
577
+ * Filters the query string or fragment of a URI.
578
+ *
579
+ * @param string $str
580
+ *
581
+ * @return string
582
+ *
583
+ * @throws \InvalidArgumentException If the query or fragment is invalid.
584
+ */
585
+ private function filterQueryAndFragment($str)
586
+ {
587
+ if (!is_string($str)) {
588
+ throw new \InvalidArgumentException('Query and fragment must be a string');
589
+ }
590
+
591
+ return preg_replace_callback(
592
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
593
+ [$this, 'rawurlencodeMatchZero'],
594
+ $str
595
+ );
596
+ }
597
+
598
+ private function rawurlencodeMatchZero(array $match)
599
+ {
600
+ return rawurlencode($match[0]);
601
+ }
602
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/functions.php ADDED
@@ -0,0 +1,826 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Psr7;
3
+
4
+ use Psr\Http\Message\MessageInterface;
5
+ use Psr\Http\Message\RequestInterface;
6
+ use Psr\Http\Message\ResponseInterface;
7
+ use Psr\Http\Message\ServerRequestInterface;
8
+ use Psr\Http\Message\StreamInterface;
9
+ use Psr\Http\Message\UriInterface;
10
+
11
+ /**
12
+ * Returns the string representation of an HTTP message.
13
+ *
14
+ * @param MessageInterface $message Message to convert to a string.
15
+ *
16
+ * @return string
17
+ */
18
+ function str(MessageInterface $message)
19
+ {
20
+ if ($message instanceof RequestInterface) {
21
+ $msg = trim($message->getMethod() . ' '
22
+ . $message->getRequestTarget())
23
+ . ' HTTP/' . $message->getProtocolVersion();
24
+ if (!$message->hasHeader('host')) {
25
+ $msg .= "\r\nHost: " . $message->getUri()->getHost();
26
+ }
27
+ } elseif ($message instanceof ResponseInterface) {
28
+ $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
29
+ . $message->getStatusCode() . ' '
30
+ . $message->getReasonPhrase();
31
+ } else {
32
+ throw new \InvalidArgumentException('Unknown message type');
33
+ }
34
+
35
+ foreach ($message->getHeaders() as $name => $values) {
36
+ $msg .= "\r\n{$name}: " . implode(', ', $values);
37
+ }
38
+
39
+ return "{$msg}\r\n\r\n" . $message->getBody();
40
+ }
41
+
42
+ /**
43
+ * Returns a UriInterface for the given value.
44
+ *
45
+ * This function accepts a string or {@see Psr\Http\Message\UriInterface} and
46
+ * returns a UriInterface for the given value. If the value is already a
47
+ * `UriInterface`, it is returned as-is.
48
+ *
49
+ * @param string|UriInterface $uri
50
+ *
51
+ * @return UriInterface
52
+ * @throws \InvalidArgumentException
53
+ */
54
+ function uri_for($uri)
55
+ {
56
+ if ($uri instanceof UriInterface) {
57
+ return $uri;
58
+ } elseif (is_string($uri)) {
59
+ return new Uri($uri);
60
+ }
61
+
62
+ throw new \InvalidArgumentException('URI must be a string or UriInterface');
63
+ }
64
+
65
+ /**
66
+ * Create a new stream based on the input type.
67
+ *
68
+ * Options is an associative array that can contain the following keys:
69
+ * - metadata: Array of custom metadata.
70
+ * - size: Size of the stream.
71
+ *
72
+ * @param resource|string|null|int|float|bool|StreamInterface|callable $resource Entity body data
73
+ * @param array $options Additional options
74
+ *
75
+ * @return Stream
76
+ * @throws \InvalidArgumentException if the $resource arg is not valid.
77
+ */
78
+ function stream_for($resource = '', array $options = [])
79
+ {
80
+ if (is_scalar($resource)) {
81
+ $stream = fopen('php://temp', 'r+');
82
+ if ($resource !== '') {
83
+ fwrite($stream, $resource);
84
+ fseek($stream, 0);
85
+ }
86
+ return new Stream($stream, $options);
87
+ }
88
+
89
+ switch (gettype($resource)) {
90
+ case 'resource':
91
+ return new Stream($resource, $options);
92
+ case 'object':
93
+ if ($resource instanceof StreamInterface) {
94
+ return $resource;
95
+ } elseif ($resource instanceof \Iterator) {
96
+ return new PumpStream(function () use ($resource) {
97
+ if (!$resource->valid()) {
98
+ return false;
99
+ }
100
+ $result = $resource->current();
101
+ $resource->next();
102
+ return $result;
103
+ }, $options);
104
+ } elseif (method_exists($resource, '__toString')) {
105
+ return stream_for((string) $resource, $options);
106
+ }
107
+ break;
108
+ case 'NULL':
109
+ return new Stream(fopen('php://temp', 'r+'), $options);
110
+ }
111
+
112
+ if (is_callable($resource)) {
113
+ return new PumpStream($resource, $options);
114
+ }
115
+
116
+ throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource));
117
+ }
118
+
119
+ /**
120
+ * Parse an array of header values containing ";" separated data into an
121
+ * array of associative arrays representing the header key value pair
122
+ * data of the header. When a parameter does not contain a value, but just
123
+ * contains a key, this function will inject a key with a '' string value.
124
+ *
125
+ * @param string|array $header Header to parse into components.
126
+ *
127
+ * @return array Returns the parsed header values.
128
+ */
129
+ function parse_header($header)
130
+ {
131
+ static $trimmed = "\"' \n\t\r";
132
+ $params = $matches = [];
133
+
134
+ foreach (normalize_header($header) as $val) {
135
+ $part = [];
136
+ foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
137
+ if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
138
+ $m = $matches[0];
139
+ if (isset($m[1])) {
140
+ $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
141
+ } else {
142
+ $part[] = trim($m[0], $trimmed);
143
+ }
144
+ }
145
+ }
146
+ if ($part) {
147
+ $params[] = $part;
148
+ }
149
+ }
150
+
151
+ return $params;
152
+ }
153
+
154
+ /**
155
+ * Converts an array of header values that may contain comma separated
156
+ * headers into an array of headers with no comma separated values.
157
+ *
158
+ * @param string|array $header Header to normalize.
159
+ *
160
+ * @return array Returns the normalized header field values.
161
+ */
162
+ function normalize_header($header)
163
+ {
164
+ if (!is_array($header)) {
165
+ return array_map('trim', explode(',', $header));
166
+ }
167
+
168
+ $result = [];
169
+ foreach ($header as $value) {
170
+ foreach ((array) $value as $v) {
171
+ if (strpos($v, ',') === false) {
172
+ $result[] = $v;
173
+ continue;
174
+ }
175
+ foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
176
+ $result[] = trim($vv);
177
+ }
178
+ }
179
+ }
180
+
181
+ return $result;
182
+ }
183
+
184
+ /**
185
+ * Clone and modify a request with the given changes.
186
+ *
187
+ * The changes can be one of:
188
+ * - method: (string) Changes the HTTP method.
189
+ * - set_headers: (array) Sets the given headers.
190
+ * - remove_headers: (array) Remove the given headers.
191
+ * - body: (mixed) Sets the given body.
192
+ * - uri: (UriInterface) Set the URI.
193
+ * - query: (string) Set the query string value of the URI.
194
+ * - version: (string) Set the protocol version.
195
+ *
196
+ * @param RequestInterface $request Request to clone and modify.
197
+ * @param array $changes Changes to apply.
198
+ *
199
+ * @return RequestInterface
200
+ */
201
+ function modify_request(RequestInterface $request, array $changes)
202
+ {
203
+ if (!$changes) {
204
+ return $request;
205
+ }
206
+
207
+ $headers = $request->getHeaders();
208
+
209
+ if (!isset($changes['uri'])) {
210
+ $uri = $request->getUri();
211
+ } else {
212
+ // Remove the host header if one is on the URI
213
+ if ($host = $changes['uri']->getHost()) {
214
+ $changes['set_headers']['Host'] = $host;
215
+
216
+ if ($port = $changes['uri']->getPort()) {
217
+ $standardPorts = ['http' => 80, 'https' => 443];
218
+ $scheme = $changes['uri']->getScheme();
219
+ if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) {
220
+ $changes['set_headers']['Host'] .= ':'.$port;
221
+ }
222
+ }
223
+ }
224
+ $uri = $changes['uri'];
225
+ }
226
+
227
+ if (!empty($changes['remove_headers'])) {
228
+ $headers = _caseless_remove($changes['remove_headers'], $headers);
229
+ }
230
+
231
+ if (!empty($changes['set_headers'])) {
232
+ $headers = _caseless_remove(array_keys($changes['set_headers']), $headers);
233
+ $headers = $changes['set_headers'] + $headers;
234
+ }
235
+
236
+ if (isset($changes['query'])) {
237
+ $uri = $uri->withQuery($changes['query']);
238
+ }
239
+
240
+ if ($request instanceof ServerRequestInterface) {
241
+ return new ServerRequest(
242
+ isset($changes['method']) ? $changes['method'] : $request->getMethod(),
243
+ $uri,
244
+ $headers,
245
+ isset($changes['body']) ? $changes['body'] : $request->getBody(),
246
+ isset($changes['version'])
247
+ ? $changes['version']
248
+ : $request->getProtocolVersion(),
249
+ $request->getServerParams()
250
+ );
251
+ }
252
+
253
+ return new Request(
254
+ isset($changes['method']) ? $changes['method'] : $request->getMethod(),
255
+ $uri,
256
+ $headers,
257
+ isset($changes['body']) ? $changes['body'] : $request->getBody(),
258
+ isset($changes['version'])
259
+ ? $changes['version']
260
+ : $request->getProtocolVersion()
261
+ );
262
+ }
263
+
264
+ /**
265
+ * Attempts to rewind a message body and throws an exception on failure.
266
+ *
267
+ * The body of the message will only be rewound if a call to `tell()` returns a
268
+ * value other than `0`.
269
+ *
270
+ * @param MessageInterface $message Message to rewind
271
+ *
272
+ * @throws \RuntimeException
273
+ */
274
+ function rewind_body(MessageInterface $message)
275
+ {
276
+ $body = $message->getBody();
277
+
278
+ if ($body->tell()) {
279
+ $body->rewind();
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Safely opens a PHP stream resource using a filename.
285
+ *
286
+ * When fopen fails, PHP normally raises a warning. This function adds an
287
+ * error handler that checks for errors and throws an exception instead.
288
+ *
289
+ * @param string $filename File to open
290
+ * @param string $mode Mode used to open the file
291
+ *
292
+ * @return resource
293
+ * @throws \RuntimeException if the file cannot be opened
294
+ */
295
+ function try_fopen($filename, $mode)
296
+ {
297
+ $ex = null;
298
+ set_error_handler(function () use ($filename, $mode, &$ex) {
299
+ $ex = new \RuntimeException(sprintf(
300
+ 'Unable to open %s using mode %s: %s',
301
+ $filename,
302
+ $mode,
303
+ func_get_args()[1]
304
+ ));
305
+ });
306
+
307
+ $handle = fopen($filename, $mode);
308
+ restore_error_handler();
309
+
310
+ if ($ex) {
311
+ /** @var $ex \RuntimeException */
312
+ throw $ex;
313
+ }
314
+
315
+ return $handle;
316
+ }
317
+
318
+ /**
319
+ * Copy the contents of a stream into a string until the given number of
320
+ * bytes have been read.
321
+ *
322
+ * @param StreamInterface $stream Stream to read
323
+ * @param int $maxLen Maximum number of bytes to read. Pass -1
324
+ * to read the entire stream.
325
+ * @return string
326
+ * @throws \RuntimeException on error.
327
+ */
328
+ function copy_to_string(StreamInterface $stream, $maxLen = -1)
329
+ {
330
+ $buffer = '';
331
+
332
+ if ($maxLen === -1) {
333
+ while (!$stream->eof()) {
334
+ $buf = $stream->read(1048576);
335
+ // Using a loose equality here to match on '' and false.
336
+ if ($buf == null) {
337
+ break;
338
+ }
339
+ $buffer .= $buf;
340
+ }
341
+ return $buffer;
342
+ }
343
+
344
+ $len = 0;
345
+ while (!$stream->eof() && $len < $maxLen) {
346
+ $buf = $stream->read($maxLen - $len);
347
+ // Using a loose equality here to match on '' and false.
348
+ if ($buf == null) {
349
+ break;
350
+ }
351
+ $buffer .= $buf;
352
+ $len = strlen($buffer);
353
+ }
354
+
355
+ return $buffer;
356
+ }
357
+
358
+ /**
359
+ * Copy the contents of a stream into another stream until the given number
360
+ * of bytes have been read.
361
+ *
362
+ * @param StreamInterface $source Stream to read from
363
+ * @param StreamInterface $dest Stream to write to
364
+ * @param int $maxLen Maximum number of bytes to read. Pass -1
365
+ * to read the entire stream.
366
+ *
367
+ * @throws \RuntimeException on error.
368
+ */
369
+ function copy_to_stream(
370
+ StreamInterface $source,
371
+ StreamInterface $dest,
372
+ $maxLen = -1
373
+ ) {
374
+ if ($maxLen === -1) {
375
+ while (!$source->eof()) {
376
+ if (!$dest->write($source->read(1048576))) {
377
+ break;
378
+ }
379
+ }
380
+ return;
381
+ }
382
+
383
+ $bytes = 0;
384
+ while (!$source->eof()) {
385
+ $buf = $source->read($maxLen - $bytes);
386
+ if (!($len = strlen($buf))) {
387
+ break;
388
+ }
389
+ $bytes += $len;
390
+ $dest->write($buf);
391
+ if ($bytes == $maxLen) {
392
+ break;
393
+ }
394
+ }
395
+ }
396
+
397
+ /**
398
+ * Calculate a hash of a Stream
399
+ *
400
+ * @param StreamInterface $stream Stream to calculate the hash for
401
+ * @param string $algo Hash algorithm (e.g. md5, crc32, etc)
402
+ * @param bool $rawOutput Whether or not to use raw output
403
+ *
404
+ * @return string Returns the hash of the stream
405
+ * @throws \RuntimeException on error.
406
+ */
407
+ function hash(
408
+ StreamInterface $stream,
409
+ $algo,
410
+ $rawOutput = false
411
+ ) {
412
+ $pos = $stream->tell();
413
+
414
+ if ($pos > 0) {
415
+ $stream->rewind();
416
+ }
417
+
418
+ $ctx = hash_init($algo);
419
+ while (!$stream->eof()) {
420
+ hash_update($ctx, $stream->read(1048576));
421
+ }
422
+
423
+ $out = hash_final($ctx, (bool) $rawOutput);
424
+ $stream->seek($pos);
425
+
426
+ return $out;
427
+ }
428
+
429
+ /**
430
+ * Read a line from the stream up to the maximum allowed buffer length
431
+ *
432
+ * @param StreamInterface $stream Stream to read from
433
+ * @param int $maxLength Maximum buffer length
434
+ *
435
+ * @return string|bool
436
+ */
437
+ function readline(StreamInterface $stream, $maxLength = null)
438
+ {
439
+ $buffer = '';
440
+ $size = 0;
441
+
442
+ while (!$stream->eof()) {
443
+ // Using a loose equality here to match on '' and false.
444
+ if (null == ($byte = $stream->read(1))) {
445
+ return $buffer;
446
+ }
447
+ $buffer .= $byte;
448
+ // Break when a new line is found or the max length - 1 is reached
449
+ if ($byte === "\n" || ++$size === $maxLength - 1) {
450
+ break;
451
+ }
452
+ }
453
+
454
+ return $buffer;
455
+ }
456
+
457
+ /**
458
+ * Parses a request message string into a request object.
459
+ *
460
+ * @param string $message Request message string.
461
+ *
462
+ * @return Request
463
+ */
464
+ function parse_request($message)
465
+ {
466
+ $data = _parse_message($message);
467
+ $matches = [];
468
+ if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
469
+ throw new \InvalidArgumentException('Invalid request string');
470
+ }
471
+ $parts = explode(' ', $data['start-line'], 3);
472
+ $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
473
+
474
+ $request = new Request(
475
+ $parts[0],
476
+ $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1],
477
+ $data['headers'],
478
+ $data['body'],
479
+ $version
480
+ );
481
+
482
+ return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
483
+ }
484
+
485
+ /**
486
+ * Parses a response message string into a response object.
487
+ *
488
+ * @param string $message Response message string.
489
+ *
490
+ * @return Response
491
+ */
492
+ function parse_response($message)
493
+ {
494
+ $data = _parse_message($message);
495
+ if (!preg_match('/^HTTP\/.* [0-9]{3} .*/', $data['start-line'])) {
496
+ throw new \InvalidArgumentException('Invalid response string');
497
+ }
498
+ $parts = explode(' ', $data['start-line'], 3);
499
+
500
+ return new Response(
501
+ $parts[1],
502
+ $data['headers'],
503
+ $data['body'],
504
+ explode('/', $parts[0])[1],
505
+ isset($parts[2]) ? $parts[2] : null
506
+ );
507
+ }
508
+
509
+ /**
510
+ * Parse a query string into an associative array.
511
+ *
512
+ * If multiple values are found for the same key, the value of that key
513
+ * value pair will become an array. This function does not parse nested
514
+ * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will
515
+ * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).
516
+ *
517
+ * @param string $str Query string to parse
518
+ * @param bool|string $urlEncoding How the query string is encoded
519
+ *
520
+ * @return array
521
+ */
522
+ function parse_query($str, $urlEncoding = true)
523
+ {
524
+ $result = [];
525
+
526
+ if ($str === '') {
527
+ return $result;
528
+ }
529
+
530
+ if ($urlEncoding === true) {
531
+ $decoder = function ($value) {
532
+ return rawurldecode(str_replace('+', ' ', $value));
533
+ };
534
+ } elseif ($urlEncoding == PHP_QUERY_RFC3986) {
535
+ $decoder = 'rawurldecode';
536
+ } elseif ($urlEncoding == PHP_QUERY_RFC1738) {
537
+ $decoder = 'urldecode';
538
+ } else {
539
+ $decoder = function ($str) { return $str; };
540
+ }
541
+
542
+ foreach (explode('&', $str) as $kvp) {
543
+ $parts = explode('=', $kvp, 2);
544
+ $key = $decoder($parts[0]);
545
+ $value = isset($parts[1]) ? $decoder($parts[1]) : null;
546
+ if (!isset($result[$key])) {
547
+ $result[$key] = $value;
548
+ } else {
549
+ if (!is_array($result[$key])) {
550
+ $result[$key] = [$result[$key]];
551
+ }
552
+ $result[$key][] = $value;
553
+ }
554
+ }
555
+
556
+ return $result;
557
+ }
558
+
559
+ /**
560
+ * Build a query string from an array of key value pairs.
561
+ *
562
+ * This function can use the return value of parse_query() to build a query
563
+ * string. This function does not modify the provided keys when an array is
564
+ * encountered (like http_build_query would).
565
+ *
566
+ * @param array $params Query string parameters.
567
+ * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
568
+ * to encode using RFC3986, or PHP_QUERY_RFC1738
569
+ * to encode using RFC1738.
570
+ * @return string
571
+ */
572
+ function build_query(array $params, $encoding = PHP_QUERY_RFC3986)
573
+ {
574
+ if (!$params) {
575
+ return '';
576
+ }
577
+
578
+ if ($encoding === false) {
579
+ $encoder = function ($str) { return $str; };
580
+ } elseif ($encoding === PHP_QUERY_RFC3986) {
581
+ $encoder = 'rawurlencode';
582
+ } elseif ($encoding === PHP_QUERY_RFC1738) {
583
+ $encoder = 'urlencode';
584
+ } else {
585
+ throw new \InvalidArgumentException('Invalid type');
586
+ }
587
+
588
+ $qs = '';
589
+ foreach ($params as $k => $v) {
590
+ $k = $encoder($k);
591
+ if (!is_array($v)) {
592
+ $qs .= $k;
593
+ if ($v !== null) {
594
+ $qs .= '=' . $encoder($v);
595
+ }
596
+ $qs .= '&';
597
+ } else {
598
+ foreach ($v as $vv) {
599
+ $qs .= $k;
600
+ if ($vv !== null) {
601
+ $qs .= '=' . $encoder($vv);
602
+ }
603
+ $qs .= '&';
604
+ }
605
+ }
606
+ }
607
+
608
+ return $qs ? (string) substr($qs, 0, -1) : '';
609
+ }
610
+
611
+ /**
612
+ * Determines the mimetype of a file by looking at its extension.
613
+ *
614
+ * @param $filename
615
+ *
616
+ * @return null|string
617
+ */
618
+ function mimetype_from_filename($filename)
619
+ {
620
+ return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION));
621
+ }
622
+
623
+ /**
624
+ * Maps a file extensions to a mimetype.
625
+ *
626
+ * @param $extension string The file extension.
627
+ *
628
+ * @return string|null
629
+ * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
630
+ */
631
+ function mimetype_from_extension($extension)
632
+ {
633
+ static $mimetypes = [
634
+ '7z' => 'application/x-7z-compressed',
635
+ 'aac' => 'audio/x-aac',
636
+ 'ai' => 'application/postscript',
637
+ 'aif' => 'audio/x-aiff',
638
+ 'asc' => 'text/plain',
639
+ 'asf' => 'video/x-ms-asf',
640
+ 'atom' => 'application/atom+xml',
641
+ 'avi' => 'video/x-msvideo',
642
+ 'bmp' => 'image/bmp',
643
+ 'bz2' => 'application/x-bzip2',
644
+ 'cer' => 'application/pkix-cert',
645
+ 'crl' => 'application/pkix-crl',
646
+ 'crt' => 'application/x-x509-ca-cert',
647
+ 'css' => 'text/css',
648
+ 'csv' => 'text/csv',
649
+ 'cu' => 'application/cu-seeme',
650
+ 'deb' => 'application/x-debian-package',
651
+ 'doc' => 'application/msword',
652
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
653
+ 'dvi' => 'application/x-dvi',
654
+ 'eot' => 'application/vnd.ms-fontobject',
655
+ 'eps' => 'application/postscript',
656
+ 'epub' => 'application/epub+zip',
657
+ 'etx' => 'text/x-setext',
658
+ 'flac' => 'audio/flac',
659
+ 'flv' => 'video/x-flv',
660
+ 'gif' => 'image/gif',
661
+ 'gz' => 'application/gzip',
662
+ 'htm' => 'text/html',
663
+ 'html' => 'text/html',
664
+ 'ico' => 'image/x-icon',
665
+ 'ics' => 'text/calendar',
666
+ 'ini' => 'text/plain',
667
+ 'iso' => 'application/x-iso9660-image',
668
+ 'jar' => 'application/java-archive',
669
+ 'jpe' => 'image/jpeg',
670
+ 'jpeg' => 'image/jpeg',
671
+ 'jpg' => 'image/jpeg',
672
+ 'js' => 'text/javascript',
673
+ 'json' => 'application/json',
674
+ 'latex' => 'application/x-latex',
675
+ 'log' => 'text/plain',
676
+ 'm4a' => 'audio/mp4',
677
+ 'm4v' => 'video/mp4',
678
+ 'mid' => 'audio/midi',
679
+ 'midi' => 'audio/midi',
680
+ 'mov' => 'video/quicktime',
681
+ 'mp3' => 'audio/mpeg',
682
+ 'mp4' => 'video/mp4',
683
+ 'mp4a' => 'audio/mp4',
684
+ 'mp4v' => 'video/mp4',
685
+ 'mpe' => 'video/mpeg',
686
+ 'mpeg' => 'video/mpeg',
687
+ 'mpg' => 'video/mpeg',
688
+ 'mpg4' => 'video/mp4',
689
+ 'oga' => 'audio/ogg',
690
+ 'ogg' => 'audio/ogg',
691
+ 'ogv' => 'video/ogg',
692
+ 'ogx' => 'application/ogg',
693
+ 'pbm' => 'image/x-portable-bitmap',
694
+ 'pdf' => 'application/pdf',
695
+ 'pgm' => 'image/x-portable-graymap',
696
+ 'png' => 'image/png',
697
+ 'pnm' => 'image/x-portable-anymap',
698
+ 'ppm' => 'image/x-portable-pixmap',
699
+ 'ppt' => 'application/vnd.ms-powerpoint',
700
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
701
+ 'ps' => 'application/postscript',
702
+ 'qt' => 'video/quicktime',
703
+ 'rar' => 'application/x-rar-compressed',
704
+ 'ras' => 'image/x-cmu-raster',
705
+ 'rss' => 'application/rss+xml',
706
+ 'rtf' => 'application/rtf',
707
+ 'sgm' => 'text/sgml',
708
+ 'sgml' => 'text/sgml',
709
+ 'svg' => 'image/svg+xml',
710
+ 'swf' => 'application/x-shockwave-flash',
711
+ 'tar' => 'application/x-tar',
712
+ 'tif' => 'image/tiff',
713
+ 'tiff' => 'image/tiff',
714
+ 'torrent' => 'application/x-bittorrent',
715
+ 'ttf' => 'application/x-font-ttf',
716
+ 'txt' => 'text/plain',
717
+ 'wav' => 'audio/x-wav',
718
+ 'webm' => 'video/webm',
719
+ 'wma' => 'audio/x-ms-wma',
720
+ 'wmv' => 'video/x-ms-wmv',
721
+ 'woff' => 'application/x-font-woff',
722
+ 'wsdl' => 'application/wsdl+xml',
723
+ 'xbm' => 'image/x-xbitmap',
724
+ 'xls' => 'application/vnd.ms-excel',
725
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
726
+ 'xml' => 'application/xml',
727
+ 'xpm' => 'image/x-xpixmap',
728
+ 'xwd' => 'image/x-xwindowdump',
729
+ 'yaml' => 'text/yaml',
730
+ 'yml' => 'text/yaml',
731
+ 'zip' => 'application/zip',
732
+ ];
733
+
734
+ $extension = strtolower($extension);
735
+
736
+ return isset($mimetypes[$extension])
737
+ ? $mimetypes[$extension]
738
+ : null;
739
+ }
740
+
741
+ /**
742
+ * Parses an HTTP message into an associative array.
743
+ *
744
+ * The array contains the "start-line" key containing the start line of
745
+ * the message, "headers" key containing an associative array of header
746
+ * array values, and a "body" key containing the body of the message.
747
+ *
748
+ * @param string $message HTTP request or response to parse.
749
+ *
750
+ * @return array
751
+ * @internal
752
+ */
753
+ function _parse_message($message)
754
+ {
755
+ if (!$message) {
756
+ throw new \InvalidArgumentException('Invalid message');
757
+ }
758
+
759
+ // Iterate over each line in the message, accounting for line endings
760
+ $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
761
+ $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => ''];
762
+ array_shift($lines);
763
+
764
+ for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) {
765
+ $line = $lines[$i];
766
+ // If two line breaks were encountered, then this is the end of body
767
+ if (empty($line)) {
768
+ if ($i < $totalLines - 1) {
769
+ $result['body'] = implode('', array_slice($lines, $i + 2));
770
+ }
771
+ break;
772
+ }
773
+ if (strpos($line, ':')) {
774
+ $parts = explode(':', $line, 2);
775
+ $key = trim($parts[0]);
776
+ $value = isset($parts[1]) ? trim($parts[1]) : '';
777
+ $result['headers'][$key][] = $value;
778
+ }
779
+ }
780
+
781
+ return $result;
782
+ }
783
+
784
+ /**
785
+ * Constructs a URI for an HTTP request message.
786
+ *
787
+ * @param string $path Path from the start-line
788
+ * @param array $headers Array of headers (each value an array).
789
+ *
790
+ * @return string
791
+ * @internal
792
+ */
793
+ function _parse_request_uri($path, array $headers)
794
+ {
795
+ $hostKey = array_filter(array_keys($headers), function ($k) {
796
+ return strtolower($k) === 'host';
797
+ });
798
+
799
+ // If no host is found, then a full URI cannot be constructed.
800
+ if (!$hostKey) {
801
+ return $path;
802
+ }
803
+
804
+ $host = $headers[reset($hostKey)][0];
805
+ $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
806
+
807
+ return $scheme . '://' . $host . '/' . ltrim($path, '/');
808
+ }
809
+
810
+ /** @internal */
811
+ function _caseless_remove($keys, array $data)
812
+ {
813
+ $result = [];
814
+
815
+ foreach ($keys as &$key) {
816
+ $key = strtolower($key);
817
+ }
818
+
819
+ foreach ($data as $k => $v) {
820
+ if (!in_array(strtolower($k), $keys)) {
821
+ $result[$k] = $v;
822
+ }
823
+ }
824
+
825
+ return $result;
826
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/src/functions_include.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('GuzzleHttp\Psr7\str')) {
5
+ require __DIR__ . '/functions.php';
6
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/AppendStreamTest.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\AppendStream;
5
+ use GuzzleHttp\Psr7;
6
+
7
+ class AppendStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ /**
10
+ * @expectedException \InvalidArgumentException
11
+ * @expectedExceptionMessage Each stream must be readable
12
+ */
13
+ public function testValidatesStreamsAreReadable()
14
+ {
15
+ $a = new AppendStream();
16
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
17
+ ->setMethods(['isReadable'])
18
+ ->getMockForAbstractClass();
19
+ $s->expects($this->once())
20
+ ->method('isReadable')
21
+ ->will($this->returnValue(false));
22
+ $a->addStream($s);
23
+ }
24
+
25
+ /**
26
+ * @expectedException \RuntimeException
27
+ * @expectedExceptionMessage The AppendStream can only seek with SEEK_SET
28
+ */
29
+ public function testValidatesSeekType()
30
+ {
31
+ $a = new AppendStream();
32
+ $a->seek(100, SEEK_CUR);
33
+ }
34
+
35
+ /**
36
+ * @expectedException \RuntimeException
37
+ * @expectedExceptionMessage Unable to seek stream 0 of the AppendStream
38
+ */
39
+ public function testTriesToRewindOnSeek()
40
+ {
41
+ $a = new AppendStream();
42
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
43
+ ->setMethods(['isReadable', 'rewind', 'isSeekable'])
44
+ ->getMockForAbstractClass();
45
+ $s->expects($this->once())
46
+ ->method('isReadable')
47
+ ->will($this->returnValue(true));
48
+ $s->expects($this->once())
49
+ ->method('isSeekable')
50
+ ->will($this->returnValue(true));
51
+ $s->expects($this->once())
52
+ ->method('rewind')
53
+ ->will($this->throwException(new \RuntimeException()));
54
+ $a->addStream($s);
55
+ $a->seek(10);
56
+ }
57
+
58
+ public function testSeeksToPositionByReading()
59
+ {
60
+ $a = new AppendStream([
61
+ Psr7\stream_for('foo'),
62
+ Psr7\stream_for('bar'),
63
+ Psr7\stream_for('baz'),
64
+ ]);
65
+
66
+ $a->seek(3);
67
+ $this->assertEquals(3, $a->tell());
68
+ $this->assertEquals('bar', $a->read(3));
69
+
70
+ $a->seek(6);
71
+ $this->assertEquals(6, $a->tell());
72
+ $this->assertEquals('baz', $a->read(3));
73
+ }
74
+
75
+ public function testDetachesEachStream()
76
+ {
77
+ $s1 = Psr7\stream_for('foo');
78
+ $s2 = Psr7\stream_for('bar');
79
+ $a = new AppendStream([$s1, $s2]);
80
+ $this->assertSame('foobar', (string) $a);
81
+ $a->detach();
82
+ $this->assertSame('', (string) $a);
83
+ $this->assertSame(0, $a->getSize());
84
+ }
85
+
86
+ public function testClosesEachStream()
87
+ {
88
+ $s1 = Psr7\stream_for('foo');
89
+ $a = new AppendStream([$s1]);
90
+ $a->close();
91
+ $this->assertSame('', (string) $a);
92
+ }
93
+
94
+ /**
95
+ * @expectedExceptionMessage Cannot write to an AppendStream
96
+ * @expectedException \RuntimeException
97
+ */
98
+ public function testIsNotWritable()
99
+ {
100
+ $a = new AppendStream([Psr7\stream_for('foo')]);
101
+ $this->assertFalse($a->isWritable());
102
+ $this->assertTrue($a->isSeekable());
103
+ $this->assertTrue($a->isReadable());
104
+ $a->write('foo');
105
+ }
106
+
107
+ public function testDoesNotNeedStreams()
108
+ {
109
+ $a = new AppendStream();
110
+ $this->assertEquals('', (string) $a);
111
+ }
112
+
113
+ public function testCanReadFromMultipleStreams()
114
+ {
115
+ $a = new AppendStream([
116
+ Psr7\stream_for('foo'),
117
+ Psr7\stream_for('bar'),
118
+ Psr7\stream_for('baz'),
119
+ ]);
120
+ $this->assertFalse($a->eof());
121
+ $this->assertSame(0, $a->tell());
122
+ $this->assertEquals('foo', $a->read(3));
123
+ $this->assertEquals('bar', $a->read(3));
124
+ $this->assertEquals('baz', $a->read(3));
125
+ $this->assertSame('', $a->read(1));
126
+ $this->assertTrue($a->eof());
127
+ $this->assertSame(9, $a->tell());
128
+ $this->assertEquals('foobarbaz', (string) $a);
129
+ }
130
+
131
+ public function testCanDetermineSizeFromMultipleStreams()
132
+ {
133
+ $a = new AppendStream([
134
+ Psr7\stream_for('foo'),
135
+ Psr7\stream_for('bar')
136
+ ]);
137
+ $this->assertEquals(6, $a->getSize());
138
+
139
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
140
+ ->setMethods(['isSeekable', 'isReadable'])
141
+ ->getMockForAbstractClass();
142
+ $s->expects($this->once())
143
+ ->method('isSeekable')
144
+ ->will($this->returnValue(null));
145
+ $s->expects($this->once())
146
+ ->method('isReadable')
147
+ ->will($this->returnValue(true));
148
+ $a->addStream($s);
149
+ $this->assertNull($a->getSize());
150
+ }
151
+
152
+ public function testCatchesExceptionsWhenCastingToString()
153
+ {
154
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
155
+ ->setMethods(['isSeekable', 'read', 'isReadable', 'eof'])
156
+ ->getMockForAbstractClass();
157
+ $s->expects($this->once())
158
+ ->method('isSeekable')
159
+ ->will($this->returnValue(true));
160
+ $s->expects($this->once())
161
+ ->method('read')
162
+ ->will($this->throwException(new \RuntimeException('foo')));
163
+ $s->expects($this->once())
164
+ ->method('isReadable')
165
+ ->will($this->returnValue(true));
166
+ $s->expects($this->any())
167
+ ->method('eof')
168
+ ->will($this->returnValue(false));
169
+ $a = new AppendStream([$s]);
170
+ $this->assertFalse($a->eof());
171
+ $this->assertSame('', (string) $a);
172
+ }
173
+
174
+ public function testCanDetach()
175
+ {
176
+ $s = new AppendStream();
177
+ $s->detach();
178
+ }
179
+
180
+ public function testReturnsEmptyMetadata()
181
+ {
182
+ $s = new AppendStream();
183
+ $this->assertEquals([], $s->getMetadata());
184
+ $this->assertNull($s->getMetadata('foo'));
185
+ }
186
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\BufferStream;
5
+
6
+ class BufferStreamTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ public function testHasMetadata()
9
+ {
10
+ $b = new BufferStream(10);
11
+ $this->assertTrue($b->isReadable());
12
+ $this->assertTrue($b->isWritable());
13
+ $this->assertFalse($b->isSeekable());
14
+ $this->assertEquals(null, $b->getMetadata('foo'));
15
+ $this->assertEquals(10, $b->getMetadata('hwm'));
16
+ $this->assertEquals([], $b->getMetadata());
17
+ }
18
+
19
+ public function testRemovesReadDataFromBuffer()
20
+ {
21
+ $b = new BufferStream();
22
+ $this->assertEquals(3, $b->write('foo'));
23
+ $this->assertEquals(3, $b->getSize());
24
+ $this->assertFalse($b->eof());
25
+ $this->assertEquals('foo', $b->read(10));
26
+ $this->assertTrue($b->eof());
27
+ $this->assertEquals('', $b->read(10));
28
+ }
29
+
30
+ /**
31
+ * @expectedException \RuntimeException
32
+ * @expectedExceptionMessage Cannot determine the position of a BufferStream
33
+ */
34
+ public function testCanCastToStringOrGetContents()
35
+ {
36
+ $b = new BufferStream();
37
+ $b->write('foo');
38
+ $b->write('baz');
39
+ $this->assertEquals('foo', $b->read(3));
40
+ $b->write('bar');
41
+ $this->assertEquals('bazbar', (string) $b);
42
+ $b->tell();
43
+ }
44
+
45
+ public function testDetachClearsBuffer()
46
+ {
47
+ $b = new BufferStream();
48
+ $b->write('foo');
49
+ $b->detach();
50
+ $this->assertTrue($b->eof());
51
+ $this->assertEquals(3, $b->write('abc'));
52
+ $this->assertEquals('abc', $b->read(10));
53
+ }
54
+
55
+ public function testExceedingHighwaterMarkReturnsFalseButStillBuffers()
56
+ {
57
+ $b = new BufferStream(5);
58
+ $this->assertEquals(3, $b->write('hi '));
59
+ $this->assertFalse($b->write('hello'));
60
+ $this->assertEquals('hi hello', (string) $b);
61
+ $this->assertEquals(4, $b->write('test'));
62
+ }
63
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\CachingStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\CachingStream
9
+ */
10
+ class CachingStreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /** @var CachingStream */
13
+ protected $body;
14
+ protected $decorated;
15
+
16
+ public function setUp()
17
+ {
18
+ $this->decorated = Psr7\stream_for('testing');
19
+ $this->body = new CachingStream($this->decorated);
20
+ }
21
+
22
+ public function tearDown()
23
+ {
24
+ $this->decorated->close();
25
+ $this->body->close();
26
+ }
27
+
28
+ public function testUsesRemoteSizeIfPossible()
29
+ {
30
+ $body = Psr7\stream_for('test');
31
+ $caching = new CachingStream($body);
32
+ $this->assertEquals(4, $caching->getSize());
33
+ }
34
+
35
+ public function testReadsUntilCachedToByte()
36
+ {
37
+ $this->body->seek(5);
38
+ $this->assertEquals('n', $this->body->read(1));
39
+ $this->body->seek(0);
40
+ $this->assertEquals('t', $this->body->read(1));
41
+ }
42
+
43
+ public function testCanSeekNearEndWithSeekEnd()
44
+ {
45
+ $baseStream = Psr7\stream_for(implode('', range('a', 'z')));
46
+ $cached = new CachingStream($baseStream);
47
+ $cached->seek(-1, SEEK_END);
48
+ $this->assertEquals(25, $baseStream->tell());
49
+ $this->assertEquals('z', $cached->read(1));
50
+ $this->assertEquals(26, $cached->getSize());
51
+ }
52
+
53
+ public function testCanSeekToEndWithSeekEnd()
54
+ {
55
+ $baseStream = Psr7\stream_for(implode('', range('a', 'z')));
56
+ $cached = new CachingStream($baseStream);
57
+ $cached->seek(0, SEEK_END);
58
+ $this->assertEquals(26, $baseStream->tell());
59
+ $this->assertEquals('', $cached->read(1));
60
+ $this->assertEquals(26, $cached->getSize());
61
+ }
62
+
63
+ public function testCanUseSeekEndWithUnknownSize()
64
+ {
65
+ $baseStream = Psr7\stream_for('testing');
66
+ $decorated = Psr7\FnStream::decorate($baseStream, [
67
+ 'getSize' => function () { return null; }
68
+ ]);
69
+ $cached = new CachingStream($decorated);
70
+ $cached->seek(-1, SEEK_END);
71
+ $this->assertEquals('g', $cached->read(1));
72
+ }
73
+
74
+ public function testRewindUsesSeek()
75
+ {
76
+ $a = Psr7\stream_for('foo');
77
+ $d = $this->getMockBuilder('GuzzleHttp\Psr7\CachingStream')
78
+ ->setMethods(array('seek'))
79
+ ->setConstructorArgs(array($a))
80
+ ->getMock();
81
+ $d->expects($this->once())
82
+ ->method('seek')
83
+ ->with(0)
84
+ ->will($this->returnValue(true));
85
+ $d->seek(0);
86
+ }
87
+
88
+ public function testCanSeekToReadBytes()
89
+ {
90
+ $this->assertEquals('te', $this->body->read(2));
91
+ $this->body->seek(0);
92
+ $this->assertEquals('test', $this->body->read(4));
93
+ $this->assertEquals(4, $this->body->tell());
94
+ $this->body->seek(2);
95
+ $this->assertEquals(2, $this->body->tell());
96
+ $this->body->seek(2, SEEK_CUR);
97
+ $this->assertEquals(4, $this->body->tell());
98
+ $this->assertEquals('ing', $this->body->read(3));
99
+ }
100
+
101
+ public function testCanSeekToReadBytesWithPartialBodyReturned()
102
+ {
103
+ $stream = fopen('php://temp', 'r+');
104
+ fwrite($stream, 'testing');
105
+ fseek($stream, 0);
106
+
107
+ $this->decorated = $this->getMockBuilder('\GuzzleHttp\Psr7\Stream')
108
+ ->setConstructorArgs([$stream])
109
+ ->setMethods(['read'])
110
+ ->getMock();
111
+
112
+ $this->decorated->expects($this->exactly(2))
113
+ ->method('read')
114
+ ->willReturnCallback(function($length) use ($stream){
115
+ return fread($stream, 2);
116
+ });
117
+
118
+ $this->body = new CachingStream($this->decorated);
119
+
120
+ $this->assertEquals(0, $this->body->tell());
121
+ $this->body->seek(4, SEEK_SET);
122
+ $this->assertEquals(4, $this->body->tell());
123
+
124
+ $this->body->seek(0);
125
+ $this->assertEquals('test', $this->body->read(4));
126
+ }
127
+
128
+ public function testWritesToBufferStream()
129
+ {
130
+ $this->body->read(2);
131
+ $this->body->write('hi');
132
+ $this->body->seek(0);
133
+ $this->assertEquals('tehiing', (string) $this->body);
134
+ }
135
+
136
+ public function testSkipsOverwrittenBytes()
137
+ {
138
+ $decorated = Psr7\stream_for(
139
+ implode("\n", array_map(function ($n) {
140
+ return str_pad($n, 4, '0', STR_PAD_LEFT);
141
+ }, range(0, 25)))
142
+ );
143
+
144
+ $body = new CachingStream($decorated);
145
+
146
+ $this->assertEquals("0000\n", Psr7\readline($body));
147
+ $this->assertEquals("0001\n", Psr7\readline($body));
148
+ // Write over part of the body yet to be read, so skip some bytes
149
+ $this->assertEquals(5, $body->write("TEST\n"));
150
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
151
+ // Read, which skips bytes, then reads
152
+ $this->assertEquals("0003\n", Psr7\readline($body));
153
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
154
+ $this->assertEquals("0004\n", Psr7\readline($body));
155
+ $this->assertEquals("0005\n", Psr7\readline($body));
156
+
157
+ // Overwrite part of the cached body (so don't skip any bytes)
158
+ $body->seek(5);
159
+ $this->assertEquals(5, $body->write("ABCD\n"));
160
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
161
+ $this->assertEquals("TEST\n", Psr7\readline($body));
162
+ $this->assertEquals("0003\n", Psr7\readline($body));
163
+ $this->assertEquals("0004\n", Psr7\readline($body));
164
+ $this->assertEquals("0005\n", Psr7\readline($body));
165
+ $this->assertEquals("0006\n", Psr7\readline($body));
166
+ $this->assertEquals(5, $body->write("1234\n"));
167
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
168
+
169
+ // Seek to 0 and ensure the overwritten bit is replaced
170
+ $body->seek(0);
171
+ $this->assertEquals("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", $body->read(50));
172
+
173
+ // Ensure that casting it to a string does not include the bit that was overwritten
174
+ $this->assertContains("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", (string) $body);
175
+ }
176
+
177
+ public function testClosesBothStreams()
178
+ {
179
+ $s = fopen('php://temp', 'r');
180
+ $a = Psr7\stream_for($s);
181
+ $d = new CachingStream($a);
182
+ $d->close();
183
+ $this->assertFalse(is_resource($s));
184
+ }
185
+
186
+ /**
187
+ * @expectedException \InvalidArgumentException
188
+ */
189
+ public function testEnsuresValidWhence()
190
+ {
191
+ $this->body->seek(10, -123456);
192
+ }
193
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\BufferStream;
5
+ use GuzzleHttp\Psr7\DroppingStream;
6
+
7
+ class DroppingStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testBeginsDroppingWhenSizeExceeded()
10
+ {
11
+ $stream = new BufferStream();
12
+ $drop = new DroppingStream($stream, 5);
13
+ $this->assertEquals(3, $drop->write('hel'));
14
+ $this->assertEquals(2, $drop->write('lo'));
15
+ $this->assertEquals(5, $drop->getSize());
16
+ $this->assertEquals('hello', $drop->read(5));
17
+ $this->assertEquals(0, $drop->getSize());
18
+ $drop->write('12345678910');
19
+ $this->assertEquals(5, $stream->getSize());
20
+ $this->assertEquals(5, $drop->getSize());
21
+ $this->assertEquals('12345', (string) $drop);
22
+ $this->assertEquals(0, $drop->getSize());
23
+ $drop->write('hello');
24
+ $this->assertSame(0, $drop->write('test'));
25
+ }
26
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/FnStreamTest.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\FnStream
9
+ */
10
+ class FnStreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /**
13
+ * @expectedException \BadMethodCallException
14
+ * @expectedExceptionMessage seek() is not implemented in the FnStream
15
+ */
16
+ public function testThrowsWhenNotImplemented()
17
+ {
18
+ (new FnStream([]))->seek(1);
19
+ }
20
+
21
+ public function testProxiesToFunction()
22
+ {
23
+ $s = new FnStream([
24
+ 'read' => function ($len) {
25
+ $this->assertEquals(3, $len);
26
+ return 'foo';
27
+ }
28
+ ]);
29
+
30
+ $this->assertEquals('foo', $s->read(3));
31
+ }
32
+
33
+ public function testCanCloseOnDestruct()
34
+ {
35
+ $called = false;
36
+ $s = new FnStream([
37
+ 'close' => function () use (&$called) {
38
+ $called = true;
39
+ }
40
+ ]);
41
+ unset($s);
42
+ $this->assertTrue($called);
43
+ }
44
+
45
+ public function testDoesNotRequireClose()
46
+ {
47
+ $s = new FnStream([]);
48
+ unset($s);
49
+ }
50
+
51
+ public function testDecoratesStream()
52
+ {
53
+ $a = Psr7\stream_for('foo');
54
+ $b = FnStream::decorate($a, []);
55
+ $this->assertEquals(3, $b->getSize());
56
+ $this->assertEquals($b->isWritable(), true);
57
+ $this->assertEquals($b->isReadable(), true);
58
+ $this->assertEquals($b->isSeekable(), true);
59
+ $this->assertEquals($b->read(3), 'foo');
60
+ $this->assertEquals($b->tell(), 3);
61
+ $this->assertEquals($a->tell(), 3);
62
+ $this->assertSame('', $a->read(1));
63
+ $this->assertEquals($b->eof(), true);
64
+ $this->assertEquals($a->eof(), true);
65
+ $b->seek(0);
66
+ $this->assertEquals('foo', (string) $b);
67
+ $b->seek(0);
68
+ $this->assertEquals('foo', $b->getContents());
69
+ $this->assertEquals($a->getMetadata(), $b->getMetadata());
70
+ $b->seek(0, SEEK_END);
71
+ $b->write('bar');
72
+ $this->assertEquals('foobar', (string) $b);
73
+ $this->assertInternalType('resource', $b->detach());
74
+ $b->close();
75
+ }
76
+
77
+ public function testDecoratesWithCustomizations()
78
+ {
79
+ $called = false;
80
+ $a = Psr7\stream_for('foo');
81
+ $b = FnStream::decorate($a, [
82
+ 'read' => function ($len) use (&$called, $a) {
83
+ $called = true;
84
+ return $a->read($len);
85
+ }
86
+ ]);
87
+ $this->assertEquals('foo', $b->read(3));
88
+ $this->assertTrue($called);
89
+ }
90
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/FunctionsTest.php ADDED
@@ -0,0 +1,619 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+ use GuzzleHttp\Psr7\NoSeekStream;
7
+
8
+ class FunctionsTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ public function testCopiesToString()
11
+ {
12
+ $s = Psr7\stream_for('foobaz');
13
+ $this->assertEquals('foobaz', Psr7\copy_to_string($s));
14
+ $s->seek(0);
15
+ $this->assertEquals('foo', Psr7\copy_to_string($s, 3));
16
+ $this->assertEquals('baz', Psr7\copy_to_string($s, 3));
17
+ $this->assertEquals('', Psr7\copy_to_string($s));
18
+ }
19
+
20
+ public function testCopiesToStringStopsWhenReadFails()
21
+ {
22
+ $s1 = Psr7\stream_for('foobaz');
23
+ $s1 = FnStream::decorate($s1, [
24
+ 'read' => function () { return ''; }
25
+ ]);
26
+ $result = Psr7\copy_to_string($s1);
27
+ $this->assertEquals('', $result);
28
+ }
29
+
30
+ public function testCopiesToStream()
31
+ {
32
+ $s1 = Psr7\stream_for('foobaz');
33
+ $s2 = Psr7\stream_for('');
34
+ Psr7\copy_to_stream($s1, $s2);
35
+ $this->assertEquals('foobaz', (string) $s2);
36
+ $s2 = Psr7\stream_for('');
37
+ $s1->seek(0);
38
+ Psr7\copy_to_stream($s1, $s2, 3);
39
+ $this->assertEquals('foo', (string) $s2);
40
+ Psr7\copy_to_stream($s1, $s2, 3);
41
+ $this->assertEquals('foobaz', (string) $s2);
42
+ }
43
+
44
+ public function testStopsCopyToStreamWhenWriteFails()
45
+ {
46
+ $s1 = Psr7\stream_for('foobaz');
47
+ $s2 = Psr7\stream_for('');
48
+ $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]);
49
+ Psr7\copy_to_stream($s1, $s2);
50
+ $this->assertEquals('', (string) $s2);
51
+ }
52
+
53
+ public function testStopsCopyToSteamWhenWriteFailsWithMaxLen()
54
+ {
55
+ $s1 = Psr7\stream_for('foobaz');
56
+ $s2 = Psr7\stream_for('');
57
+ $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]);
58
+ Psr7\copy_to_stream($s1, $s2, 10);
59
+ $this->assertEquals('', (string) $s2);
60
+ }
61
+
62
+ public function testStopsCopyToSteamWhenReadFailsWithMaxLen()
63
+ {
64
+ $s1 = Psr7\stream_for('foobaz');
65
+ $s1 = FnStream::decorate($s1, ['read' => function () { return ''; }]);
66
+ $s2 = Psr7\stream_for('');
67
+ Psr7\copy_to_stream($s1, $s2, 10);
68
+ $this->assertEquals('', (string) $s2);
69
+ }
70
+
71
+ public function testReadsLines()
72
+ {
73
+ $s = Psr7\stream_for("foo\nbaz\nbar");
74
+ $this->assertEquals("foo\n", Psr7\readline($s));
75
+ $this->assertEquals("baz\n", Psr7\readline($s));
76
+ $this->assertEquals("bar", Psr7\readline($s));
77
+ }
78
+
79
+ public function testReadsLinesUpToMaxLength()
80
+ {
81
+ $s = Psr7\stream_for("12345\n");
82
+ $this->assertEquals("123", Psr7\readline($s, 4));
83
+ $this->assertEquals("45\n", Psr7\readline($s));
84
+ }
85
+
86
+ public function testReadsLineUntilFalseReturnedFromRead()
87
+ {
88
+ $s = $this->getMockBuilder('GuzzleHttp\Psr7\Stream')
89
+ ->setMethods(['read', 'eof'])
90
+ ->disableOriginalConstructor()
91
+ ->getMock();
92
+ $s->expects($this->exactly(2))
93
+ ->method('read')
94
+ ->will($this->returnCallback(function () {
95
+ static $c = false;
96
+ if ($c) {
97
+ return false;
98
+ }
99
+ $c = true;
100
+ return 'h';
101
+ }));
102
+ $s->expects($this->exactly(2))
103
+ ->method('eof')
104
+ ->will($this->returnValue(false));
105
+ $this->assertEquals("h", Psr7\readline($s));
106
+ }
107
+
108
+ public function testCalculatesHash()
109
+ {
110
+ $s = Psr7\stream_for('foobazbar');
111
+ $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5'));
112
+ }
113
+
114
+ /**
115
+ * @expectedException \RuntimeException
116
+ */
117
+ public function testCalculatesHashThrowsWhenSeekFails()
118
+ {
119
+ $s = new NoSeekStream(Psr7\stream_for('foobazbar'));
120
+ $s->read(2);
121
+ Psr7\hash($s, 'md5');
122
+ }
123
+
124
+ public function testCalculatesHashSeeksToOriginalPosition()
125
+ {
126
+ $s = Psr7\stream_for('foobazbar');
127
+ $s->seek(4);
128
+ $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5'));
129
+ $this->assertEquals(4, $s->tell());
130
+ }
131
+
132
+ public function testOpensFilesSuccessfully()
133
+ {
134
+ $r = Psr7\try_fopen(__FILE__, 'r');
135
+ $this->assertInternalType('resource', $r);
136
+ fclose($r);
137
+ }
138
+
139
+ /**
140
+ * @expectedException \RuntimeException
141
+ * @expectedExceptionMessage Unable to open /path/to/does/not/exist using mode r
142
+ */
143
+ public function testThrowsExceptionNotWarning()
144
+ {
145
+ Psr7\try_fopen('/path/to/does/not/exist', 'r');
146
+ }
147
+
148
+ public function parseQueryProvider()
149
+ {
150
+ return [
151
+ // Does not need to parse when the string is empty
152
+ ['', []],
153
+ // Can parse mult-values items
154
+ ['q=a&q=b', ['q' => ['a', 'b']]],
155
+ // Can parse multi-valued items that use numeric indices
156
+ ['q[0]=a&q[1]=b', ['q[0]' => 'a', 'q[1]' => 'b']],
157
+ // Can parse duplicates and does not include numeric indices
158
+ ['q[]=a&q[]=b', ['q[]' => ['a', 'b']]],
159
+ // Ensures that the value of "q" is an array even though one value
160
+ ['q[]=a', ['q[]' => 'a']],
161
+ // Does not modify "." to "_" like PHP's parse_str()
162
+ ['q.a=a&q.b=b', ['q.a' => 'a', 'q.b' => 'b']],
163
+ // Can decode %20 to " "
164
+ ['q%20a=a%20b', ['q a' => 'a b']],
165
+ // Can parse funky strings with no values by assigning each to null
166
+ ['q&a', ['q' => null, 'a' => null]],
167
+ // Does not strip trailing equal signs
168
+ ['data=abc=', ['data' => 'abc=']],
169
+ // Can store duplicates without affecting other values
170
+ ['foo=a&foo=b&?µ=c', ['foo' => ['a', 'b'], '?µ' => 'c']],
171
+ // Sets value to null when no "=" is present
172
+ ['foo', ['foo' => null]],
173
+ // Preserves "0" keys.
174
+ ['0', ['0' => null]],
175
+ // Sets the value to an empty string when "=" is present
176
+ ['0=', ['0' => '']],
177
+ // Preserves falsey keys
178
+ ['var=0', ['var' => '0']],
179
+ ['a[b][c]=1&a[b][c]=2', ['a[b][c]' => ['1', '2']]],
180
+ ['a[b]=c&a[d]=e', ['a[b]' => 'c', 'a[d]' => 'e']],
181
+ // Ensure it doesn't leave things behind with repeated values
182
+ // Can parse mult-values items
183
+ ['q=a&q=b&q=c', ['q' => ['a', 'b', 'c']]],
184
+ ];
185
+ }
186
+
187
+ /**
188
+ * @dataProvider parseQueryProvider
189
+ */
190
+ public function testParsesQueries($input, $output)
191
+ {
192
+ $result = Psr7\parse_query($input);
193
+ $this->assertSame($output, $result);
194
+ }
195
+
196
+ public function testDoesNotDecode()
197
+ {
198
+ $str = 'foo%20=bar';
199
+ $data = Psr7\parse_query($str, false);
200
+ $this->assertEquals(['foo%20' => 'bar'], $data);
201
+ }
202
+
203
+ /**
204
+ * @dataProvider parseQueryProvider
205
+ */
206
+ public function testParsesAndBuildsQueries($input, $output)
207
+ {
208
+ $result = Psr7\parse_query($input, false);
209
+ $this->assertSame($input, Psr7\build_query($result, false));
210
+ }
211
+
212
+ public function testEncodesWithRfc1738()
213
+ {
214
+ $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC1738);
215
+ $this->assertEquals('foo+bar=baz%2B', $str);
216
+ }
217
+
218
+ public function testEncodesWithRfc3986()
219
+ {
220
+ $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC3986);
221
+ $this->assertEquals('foo%20bar=baz%2B', $str);
222
+ }
223
+
224
+ public function testDoesNotEncode()
225
+ {
226
+ $str = Psr7\build_query(['foo bar' => 'baz+'], false);
227
+ $this->assertEquals('foo bar=baz+', $str);
228
+ }
229
+
230
+ public function testCanControlDecodingType()
231
+ {
232
+ $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC3986);
233
+ $this->assertEquals('foo+bar', $result['var']);
234
+ $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC1738);
235
+ $this->assertEquals('foo bar', $result['var']);
236
+ }
237
+
238
+ public function testParsesRequestMessages()
239
+ {
240
+ $req = "GET /abc HTTP/1.0\r\nHost: foo.com\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest";
241
+ $request = Psr7\parse_request($req);
242
+ $this->assertEquals('GET', $request->getMethod());
243
+ $this->assertEquals('/abc', $request->getRequestTarget());
244
+ $this->assertEquals('1.0', $request->getProtocolVersion());
245
+ $this->assertEquals('foo.com', $request->getHeaderLine('Host'));
246
+ $this->assertEquals('Bar', $request->getHeaderLine('Foo'));
247
+ $this->assertEquals('Bam, Qux', $request->getHeaderLine('Baz'));
248
+ $this->assertEquals('Test', (string) $request->getBody());
249
+ $this->assertEquals('http://foo.com/abc', (string) $request->getUri());
250
+ }
251
+
252
+ public function testParsesRequestMessagesWithHttpsScheme()
253
+ {
254
+ $req = "PUT /abc?baz=bar HTTP/1.1\r\nHost: foo.com:443\r\n\r\n";
255
+ $request = Psr7\parse_request($req);
256
+ $this->assertEquals('PUT', $request->getMethod());
257
+ $this->assertEquals('/abc?baz=bar', $request->getRequestTarget());
258
+ $this->assertEquals('1.1', $request->getProtocolVersion());
259
+ $this->assertEquals('foo.com:443', $request->getHeaderLine('Host'));
260
+ $this->assertEquals('', (string) $request->getBody());
261
+ $this->assertEquals('https://foo.com/abc?baz=bar', (string) $request->getUri());
262
+ }
263
+
264
+ public function testParsesRequestMessagesWithUriWhenHostIsNotFirst()
265
+ {
266
+ $req = "PUT / HTTP/1.1\r\nFoo: Bar\r\nHost: foo.com\r\n\r\n";
267
+ $request = Psr7\parse_request($req);
268
+ $this->assertEquals('PUT', $request->getMethod());
269
+ $this->assertEquals('/', $request->getRequestTarget());
270
+ $this->assertEquals('http://foo.com/', (string) $request->getUri());
271
+ }
272
+
273
+ public function testParsesRequestMessagesWithFullUri()
274
+ {
275
+ $req = "GET https://www.google.com:443/search?q=foobar HTTP/1.1\r\nHost: www.google.com\r\n\r\n";
276
+ $request = Psr7\parse_request($req);
277
+ $this->assertEquals('GET', $request->getMethod());
278
+ $this->assertEquals('https://www.google.com:443/search?q=foobar', $request->getRequestTarget());
279
+ $this->assertEquals('1.1', $request->getProtocolVersion());
280
+ $this->assertEquals('www.google.com', $request->getHeaderLine('Host'));
281
+ $this->assertEquals('', (string) $request->getBody());
282
+ $this->assertEquals('https://www.google.com/search?q=foobar', (string) $request->getUri());
283
+ }
284
+
285
+ public function testParsesRequestMessagesWithCustomMethod()
286
+ {
287
+ $req = "GET_DATA / HTTP/1.1\r\nFoo: Bar\r\nHost: foo.com\r\n\r\n";
288
+ $request = Psr7\parse_request($req);
289
+ $this->assertEquals('GET_DATA', $request->getMethod());
290
+ }
291
+
292
+ /**
293
+ * @expectedException \InvalidArgumentException
294
+ */
295
+ public function testValidatesRequestMessages()
296
+ {
297
+ Psr7\parse_request("HTTP/1.1 200 OK\r\n\r\n");
298
+ }
299
+
300
+ public function testParsesResponseMessages()
301
+ {
302
+ $res = "HTTP/1.0 200 OK\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest";
303
+ $response = Psr7\parse_response($res);
304
+ $this->assertEquals(200, $response->getStatusCode());
305
+ $this->assertEquals('OK', $response->getReasonPhrase());
306
+ $this->assertEquals('1.0', $response->getProtocolVersion());
307
+ $this->assertEquals('Bar', $response->getHeaderLine('Foo'));
308
+ $this->assertEquals('Bam, Qux', $response->getHeaderLine('Baz'));
309
+ $this->assertEquals('Test', (string) $response->getBody());
310
+ }
311
+
312
+ /**
313
+ * @expectedException \InvalidArgumentException
314
+ */
315
+ public function testValidatesResponseMessages()
316
+ {
317
+ Psr7\parse_response("GET / HTTP/1.1\r\n\r\n");
318
+ }
319
+
320
+ public function testDetermineMimetype()
321
+ {
322
+ $this->assertNull(Psr7\mimetype_from_extension('not-a-real-extension'));
323
+ $this->assertEquals(
324
+ 'application/json',
325
+ Psr7\mimetype_from_extension('json')
326
+ );
327
+ $this->assertEquals(
328
+ 'image/jpeg',
329
+ Psr7\mimetype_from_filename('/tmp/images/IMG034821.JPEG')
330
+ );
331
+ }
332
+
333
+ public function testCreatesUriForValue()
334
+ {
335
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Uri', Psr7\uri_for('/foo'));
336
+ $this->assertInstanceOf(
337
+ 'GuzzleHttp\Psr7\Uri',
338
+ Psr7\uri_for(new Psr7\Uri('/foo'))
339
+ );
340
+ }
341
+
342
+ /**
343
+ * @expectedException \InvalidArgumentException
344
+ */
345
+ public function testValidatesUri()
346
+ {
347
+ Psr7\uri_for([]);
348
+ }
349
+
350
+ public function testKeepsPositionOfResource()
351
+ {
352
+ $h = fopen(__FILE__, 'r');
353
+ fseek($h, 10);
354
+ $stream = Psr7\stream_for($h);
355
+ $this->assertEquals(10, $stream->tell());
356
+ $stream->close();
357
+ }
358
+
359
+ public function testCreatesWithFactory()
360
+ {
361
+ $stream = Psr7\stream_for('foo');
362
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $stream);
363
+ $this->assertEquals('foo', $stream->getContents());
364
+ $stream->close();
365
+ }
366
+
367
+ public function testFactoryCreatesFromEmptyString()
368
+ {
369
+ $s = Psr7\stream_for();
370
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
371
+ }
372
+
373
+ public function testFactoryCreatesFromNull()
374
+ {
375
+ $s = Psr7\stream_for(null);
376
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
377
+ }
378
+
379
+ public function testFactoryCreatesFromResource()
380
+ {
381
+ $r = fopen(__FILE__, 'r');
382
+ $s = Psr7\stream_for($r);
383
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
384
+ $this->assertSame(file_get_contents(__FILE__), (string) $s);
385
+ }
386
+
387
+ public function testFactoryCreatesFromObjectWithToString()
388
+ {
389
+ $r = new HasToString();
390
+ $s = Psr7\stream_for($r);
391
+ $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s);
392
+ $this->assertEquals('foo', (string) $s);
393
+ }
394
+
395
+ public function testCreatePassesThrough()
396
+ {
397
+ $s = Psr7\stream_for('foo');
398
+ $this->assertSame($s, Psr7\stream_for($s));
399
+ }
400
+
401
+ /**
402
+ * @expectedException \InvalidArgumentException
403
+ */
404
+ public function testThrowsExceptionForUnknown()
405
+ {
406
+ Psr7\stream_for(new \stdClass());
407
+ }
408
+
409
+ public function testReturnsCustomMetadata()
410
+ {
411
+ $s = Psr7\stream_for('foo', ['metadata' => ['hwm' => 3]]);
412
+ $this->assertEquals(3, $s->getMetadata('hwm'));
413
+ $this->assertArrayHasKey('hwm', $s->getMetadata());
414
+ }
415
+
416
+ public function testCanSetSize()
417
+ {
418
+ $s = Psr7\stream_for('', ['size' => 10]);
419
+ $this->assertEquals(10, $s->getSize());
420
+ }
421
+
422
+ public function testCanCreateIteratorBasedStream()
423
+ {
424
+ $a = new \ArrayIterator(['foo', 'bar', '123']);
425
+ $p = Psr7\stream_for($a);
426
+ $this->assertInstanceOf('GuzzleHttp\Psr7\PumpStream', $p);
427
+ $this->assertEquals('foo', $p->read(3));
428
+ $this->assertFalse($p->eof());
429
+ $this->assertEquals('b', $p->read(1));
430
+ $this->assertEquals('a', $p->read(1));
431
+ $this->assertEquals('r12', $p->read(3));
432
+ $this->assertFalse($p->eof());
433
+ $this->assertEquals('3', $p->getContents());
434
+ $this->assertTrue($p->eof());
435
+ $this->assertEquals(9, $p->tell());
436
+ }
437
+
438
+ public function testConvertsRequestsToStrings()
439
+ {
440
+ $request = new Psr7\Request('PUT', 'http://foo.com/hi?123', [
441
+ 'Baz' => 'bar',
442
+ 'Qux' => 'ipsum'
443
+ ], 'hello', '1.0');
444
+ $this->assertEquals(
445
+ "PUT /hi?123 HTTP/1.0\r\nHost: foo.com\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello",
446
+ Psr7\str($request)
447
+ );
448
+ }
449
+
450
+ public function testConvertsResponsesToStrings()
451
+ {
452
+ $response = new Psr7\Response(200, [
453
+ 'Baz' => 'bar',
454
+ 'Qux' => 'ipsum'
455
+ ], 'hello', '1.0', 'FOO');
456
+ $this->assertEquals(
457
+ "HTTP/1.0 200 FOO\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello",
458
+ Psr7\str($response)
459
+ );
460
+ }
461
+
462
+ public function parseParamsProvider()
463
+ {
464
+ $res1 = array(
465
+ array(
466
+ '<http:/.../front.jpeg>',
467
+ 'rel' => 'front',
468
+ 'type' => 'image/jpeg',
469
+ ),
470
+ array(
471
+ '<http://.../back.jpeg>',
472
+ 'rel' => 'back',
473
+ 'type' => 'image/jpeg',
474
+ ),
475
+ );
476
+ return array(
477
+ array(
478
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg", <http://.../back.jpeg>; rel=back; type="image/jpeg"',
479
+ $res1
480
+ ),
481
+ array(
482
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg",<http://.../back.jpeg>; rel=back; type="image/jpeg"',
483
+ $res1
484
+ ),
485
+ array(
486
+ 'foo="baz"; bar=123, boo, test="123", foobar="foo;bar"',
487
+ array(
488
+ array('foo' => 'baz', 'bar' => '123'),
489
+ array('boo'),
490
+ array('test' => '123'),
491
+ array('foobar' => 'foo;bar')
492
+ )
493
+ ),
494
+ array(
495
+ '<http://.../side.jpeg?test=1>; rel="side"; type="image/jpeg",<http://.../side.jpeg?test=2>; rel=side; type="image/jpeg"',
496
+ array(
497
+ array('<http://.../side.jpeg?test=1>', 'rel' => 'side', 'type' => 'image/jpeg'),
498
+ array('<http://.../side.jpeg?test=2>', 'rel' => 'side', 'type' => 'image/jpeg')
499
+ )
500
+ ),
501
+ array(
502
+ '',
503
+ array()
504
+ )
505
+ );
506
+ }
507
+ /**
508
+ * @dataProvider parseParamsProvider
509
+ */
510
+ public function testParseParams($header, $result)
511
+ {
512
+ $this->assertEquals($result, Psr7\parse_header($header));
513
+ }
514
+
515
+ public function testParsesArrayHeaders()
516
+ {
517
+ $header = ['a, b', 'c', 'd, e'];
518
+ $this->assertEquals(['a', 'b', 'c', 'd', 'e'], Psr7\normalize_header($header));
519
+ }
520
+
521
+ public function testRewindsBody()
522
+ {
523
+ $body = Psr7\stream_for('abc');
524
+ $res = new Psr7\Response(200, [], $body);
525
+ Psr7\rewind_body($res);
526
+ $this->assertEquals(0, $body->tell());
527
+ $body->rewind(1);
528
+ Psr7\rewind_body($res);
529
+ $this->assertEquals(0, $body->tell());
530
+ }
531
+
532
+ /**
533
+ * @expectedException \RuntimeException
534
+ */
535
+ public function testThrowsWhenBodyCannotBeRewound()
536
+ {
537
+ $body = Psr7\stream_for('abc');
538
+ $body->read(1);
539
+ $body = FnStream::decorate($body, [
540
+ 'rewind' => function () { throw new \RuntimeException('a'); }
541
+ ]);
542
+ $res = new Psr7\Response(200, [], $body);
543
+ Psr7\rewind_body($res);
544
+ }
545
+
546
+ public function testCanModifyRequestWithUri()
547
+ {
548
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
549
+ $r2 = Psr7\modify_request($r1, [
550
+ 'uri' => new Psr7\Uri('http://www.foo.com')
551
+ ]);
552
+ $this->assertEquals('http://www.foo.com', (string) $r2->getUri());
553
+ $this->assertEquals('www.foo.com', (string) $r2->getHeaderLine('host'));
554
+ }
555
+
556
+ public function testCanModifyRequestWithUriAndPort()
557
+ {
558
+ $r1 = new Psr7\Request('GET', 'http://foo.com:8000');
559
+ $r2 = Psr7\modify_request($r1, [
560
+ 'uri' => new Psr7\Uri('http://www.foo.com:8000')
561
+ ]);
562
+ $this->assertEquals('http://www.foo.com:8000', (string) $r2->getUri());
563
+ $this->assertEquals('www.foo.com:8000', (string) $r2->getHeaderLine('host'));
564
+ }
565
+
566
+ public function testCanModifyRequestWithCaseInsensitiveHeader()
567
+ {
568
+ $r1 = new Psr7\Request('GET', 'http://foo.com', ['User-Agent' => 'foo']);
569
+ $r2 = Psr7\modify_request($r1, ['set_headers' => ['User-agent' => 'bar']]);
570
+ $this->assertEquals('bar', $r2->getHeaderLine('User-Agent'));
571
+ $this->assertEquals('bar', $r2->getHeaderLine('User-agent'));
572
+ }
573
+
574
+ public function testReturnsAsIsWhenNoChanges()
575
+ {
576
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
577
+ $r2 = Psr7\modify_request($r1, []);
578
+ $this->assertTrue($r2 instanceof Psr7\Request);
579
+
580
+ $r1 = new Psr7\ServerRequest('GET', 'http://foo.com');
581
+ $r2 = Psr7\modify_request($r1, []);
582
+ $this->assertTrue($r2 instanceof \Psr\Http\Message\ServerRequestInterface);
583
+ }
584
+
585
+ public function testReturnsUriAsIsWhenNoChanges()
586
+ {
587
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
588
+ $r2 = Psr7\modify_request($r1, ['set_headers' => ['foo' => 'bar']]);
589
+ $this->assertNotSame($r1, $r2);
590
+ $this->assertEquals('bar', $r2->getHeaderLine('foo'));
591
+ }
592
+
593
+ public function testRemovesHeadersFromMessage()
594
+ {
595
+ $r1 = new Psr7\Request('GET', 'http://foo.com', ['foo' => 'bar']);
596
+ $r2 = Psr7\modify_request($r1, ['remove_headers' => ['foo']]);
597
+ $this->assertNotSame($r1, $r2);
598
+ $this->assertFalse($r2->hasHeader('foo'));
599
+ }
600
+
601
+ public function testAddsQueryToUri()
602
+ {
603
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
604
+ $r2 = Psr7\modify_request($r1, ['query' => 'foo=bar']);
605
+ $this->assertNotSame($r1, $r2);
606
+ $this->assertEquals('foo=bar', $r2->getUri()->getQuery());
607
+ }
608
+
609
+ public function testModifyRequestKeepInstanceOfRequest()
610
+ {
611
+ $r1 = new Psr7\Request('GET', 'http://foo.com');
612
+ $r2 = Psr7\modify_request($r1, ['remove_headers' => ['non-existent']]);
613
+ $this->assertTrue($r2 instanceof Psr7\Request);
614
+
615
+ $r1 = new Psr7\ServerRequest('GET', 'http://foo.com');
616
+ $r2 = Psr7\modify_request($r1, ['remove_headers' => ['non-existent']]);
617
+ $this->assertTrue($r2 instanceof \Psr\Http\Message\ServerRequestInterface);
618
+ }
619
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\InflateStream;
6
+
7
+ class InflateStreamtest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testInflatesStreams()
10
+ {
11
+ $content = gzencode('test');
12
+ $a = Psr7\stream_for($content);
13
+ $b = new InflateStream($a);
14
+ $this->assertEquals('test', (string) $b);
15
+ }
16
+
17
+ public function testInflatesStreamsWithFilename()
18
+ {
19
+ $content = $this->getGzipStringWithFilename('test');
20
+ $a = Psr7\stream_for($content);
21
+ $b = new InflateStream($a);
22
+ $this->assertEquals('test', (string) $b);
23
+ }
24
+
25
+ private function getGzipStringWithFilename($original_string)
26
+ {
27
+ $gzipped = bin2hex(gzencode($original_string));
28
+
29
+ $header = substr($gzipped, 0, 20);
30
+ // set FNAME flag
31
+ $header[6]=0;
32
+ $header[7]=8;
33
+ // make a dummy filename
34
+ $filename = "64756d6d7900";
35
+ $rest = substr($gzipped, 20);
36
+
37
+ return hex2bin($header . $filename . $rest);
38
+ }
39
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\LazyOpenStream;
5
+
6
+ class LazyOpenStreamTest extends \PHPUnit_Framework_TestCase
7
+ {
8
+ private $fname;
9
+
10
+ public function setup()
11
+ {
12
+ $this->fname = tempnam('/tmp', 'tfile');
13
+
14
+ if (file_exists($this->fname)) {
15
+ unlink($this->fname);
16
+ }
17
+ }
18
+
19
+ public function tearDown()
20
+ {
21
+ if (file_exists($this->fname)) {
22
+ unlink($this->fname);
23
+ }
24
+ }
25
+
26
+ public function testOpensLazily()
27
+ {
28
+ $l = new LazyOpenStream($this->fname, 'w+');
29
+ $l->write('foo');
30
+ $this->assertInternalType('array', $l->getMetadata());
31
+ $this->assertFileExists($this->fname);
32
+ $this->assertEquals('foo', file_get_contents($this->fname));
33
+ $this->assertEquals('foo', (string) $l);
34
+ }
35
+
36
+ public function testProxiesToFile()
37
+ {
38
+ file_put_contents($this->fname, 'foo');
39
+ $l = new LazyOpenStream($this->fname, 'r');
40
+ $this->assertEquals('foo', $l->read(4));
41
+ $this->assertTrue($l->eof());
42
+ $this->assertEquals(3, $l->tell());
43
+ $this->assertTrue($l->isReadable());
44
+ $this->assertTrue($l->isSeekable());
45
+ $this->assertFalse($l->isWritable());
46
+ $l->seek(1);
47
+ $this->assertEquals('oo', $l->getContents());
48
+ $this->assertEquals('foo', (string) $l);
49
+ $this->assertEquals(3, $l->getSize());
50
+ $this->assertInternalType('array', $l->getMetadata());
51
+ $l->close();
52
+ }
53
+
54
+ public function testDetachesUnderlyingStream()
55
+ {
56
+ file_put_contents($this->fname, 'foo');
57
+ $l = new LazyOpenStream($this->fname, 'r');
58
+ $r = $l->detach();
59
+ $this->assertInternalType('resource', $r);
60
+ fseek($r, 0);
61
+ $this->assertEquals('foo', stream_get_contents($r));
62
+ fclose($r);
63
+ }
64
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\FnStream;
6
+ use GuzzleHttp\Psr7\Stream;
7
+ use GuzzleHttp\Psr7\LimitStream;
8
+ use GuzzleHttp\Psr7\NoSeekStream;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Psr7\LimitStream
12
+ */
13
+ class LimitStreamTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /** @var LimitStream */
16
+ protected $body;
17
+
18
+ /** @var Stream */
19
+ protected $decorated;
20
+
21
+ public function setUp()
22
+ {
23
+ $this->decorated = Psr7\stream_for(fopen(__FILE__, 'r'));
24
+ $this->body = new LimitStream($this->decorated, 10, 3);
25
+ }
26
+
27
+ public function testReturnsSubset()
28
+ {
29
+ $body = new LimitStream(Psr7\stream_for('foo'), -1, 1);
30
+ $this->assertEquals('oo', (string) $body);
31
+ $this->assertTrue($body->eof());
32
+ $body->seek(0);
33
+ $this->assertFalse($body->eof());
34
+ $this->assertEquals('oo', $body->read(100));
35
+ $this->assertSame('', $body->read(1));
36
+ $this->assertTrue($body->eof());
37
+ }
38
+
39
+ public function testReturnsSubsetWhenCastToString()
40
+ {
41
+ $body = Psr7\stream_for('foo_baz_bar');
42
+ $limited = new LimitStream($body, 3, 4);
43
+ $this->assertEquals('baz', (string) $limited);
44
+ }
45
+
46
+ /**
47
+ * @expectedException \RuntimeException
48
+ * @expectedExceptionMessage Unable to seek to stream position 10 with whence 0
49
+ */
50
+ public function testEnsuresPositionCanBeekSeekedTo()
51
+ {
52
+ new LimitStream(Psr7\stream_for(''), 0, 10);
53
+ }
54
+
55
+ public function testReturnsSubsetOfEmptyBodyWhenCastToString()
56
+ {
57
+ $body = Psr7\stream_for('01234567891234');
58
+ $limited = new LimitStream($body, 0, 10);
59
+ $this->assertEquals('', (string) $limited);
60
+ }
61
+
62
+ public function testReturnsSpecificSubsetOBodyWhenCastToString()
63
+ {
64
+ $body = Psr7\stream_for('0123456789abcdef');
65
+ $limited = new LimitStream($body, 3, 10);
66
+ $this->assertEquals('abc', (string) $limited);
67
+ }
68
+
69
+ public function testSeeksWhenConstructed()
70
+ {
71
+ $this->assertEquals(0, $this->body->tell());
72
+ $this->assertEquals(3, $this->decorated->tell());
73
+ }
74
+
75
+ public function testAllowsBoundedSeek()
76
+ {
77
+ $this->body->seek(100);
78
+ $this->assertEquals(10, $this->body->tell());
79
+ $this->assertEquals(13, $this->decorated->tell());
80
+ $this->body->seek(0);
81
+ $this->assertEquals(0, $this->body->tell());
82
+ $this->assertEquals(3, $this->decorated->tell());
83
+ try {
84
+ $this->body->seek(-10);
85
+ $this->fail();
86
+ } catch (\RuntimeException $e) {}
87
+ $this->assertEquals(0, $this->body->tell());
88
+ $this->assertEquals(3, $this->decorated->tell());
89
+ $this->body->seek(5);
90
+ $this->assertEquals(5, $this->body->tell());
91
+ $this->assertEquals(8, $this->decorated->tell());
92
+ // Fail
93
+ try {
94
+ $this->body->seek(1000, SEEK_END);
95
+ $this->fail();
96
+ } catch (\RuntimeException $e) {}
97
+ }
98
+
99
+ public function testReadsOnlySubsetOfData()
100
+ {
101
+ $data = $this->body->read(100);
102
+ $this->assertEquals(10, strlen($data));
103
+ $this->assertSame('', $this->body->read(1000));
104
+
105
+ $this->body->setOffset(10);
106
+ $newData = $this->body->read(100);
107
+ $this->assertEquals(10, strlen($newData));
108
+ $this->assertNotSame($data, $newData);
109
+ }
110
+
111
+ /**
112
+ * @expectedException \RuntimeException
113
+ * @expectedExceptionMessage Could not seek to stream offset 2
114
+ */
115
+ public function testThrowsWhenCurrentGreaterThanOffsetSeek()
116
+ {
117
+ $a = Psr7\stream_for('foo_bar');
118
+ $b = new NoSeekStream($a);
119
+ $c = new LimitStream($b);
120
+ $a->getContents();
121
+ $c->setOffset(2);
122
+ }
123
+
124
+ public function testCanGetContentsWithoutSeeking()
125
+ {
126
+ $a = Psr7\stream_for('foo_bar');
127
+ $b = new NoSeekStream($a);
128
+ $c = new LimitStream($b);
129
+ $this->assertEquals('foo_bar', $c->getContents());
130
+ }
131
+
132
+ public function testClaimsConsumedWhenReadLimitIsReached()
133
+ {
134
+ $this->assertFalse($this->body->eof());
135
+ $this->body->read(1000);
136
+ $this->assertTrue($this->body->eof());
137
+ }
138
+
139
+ public function testContentLengthIsBounded()
140
+ {
141
+ $this->assertEquals(10, $this->body->getSize());
142
+ }
143
+
144
+ public function testGetContentsIsBasedOnSubset()
145
+ {
146
+ $body = new LimitStream(Psr7\stream_for('foobazbar'), 3, 3);
147
+ $this->assertEquals('baz', $body->getContents());
148
+ }
149
+
150
+ public function testReturnsNullIfSizeCannotBeDetermined()
151
+ {
152
+ $a = new FnStream([
153
+ 'getSize' => function () { return null; },
154
+ 'tell' => function () { return 0; },
155
+ ]);
156
+ $b = new LimitStream($a);
157
+ $this->assertNull($b->getSize());
158
+ }
159
+
160
+ public function testLengthLessOffsetWhenNoLimitSize()
161
+ {
162
+ $a = Psr7\stream_for('foo_bar');
163
+ $b = new LimitStream($a, -1, 4);
164
+ $this->assertEquals(3, $b->getSize());
165
+ }
166
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\MultipartStream;
6
+
7
+ class MultipartStreamTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testCreatesDefaultBoundary()
10
+ {
11
+ $b = new MultipartStream();
12
+ $this->assertNotEmpty($b->getBoundary());
13
+ }
14
+
15
+ public function testCanProvideBoundary()
16
+ {
17
+ $b = new MultipartStream([], 'foo');
18
+ $this->assertEquals('foo', $b->getBoundary());
19
+ }
20
+
21
+ public function testIsNotWritable()
22
+ {
23
+ $b = new MultipartStream();
24
+ $this->assertFalse($b->isWritable());
25
+ }
26
+
27
+ public function testCanCreateEmptyStream()
28
+ {
29
+ $b = new MultipartStream();
30
+ $boundary = $b->getBoundary();
31
+ $this->assertSame("--{$boundary}--\r\n", $b->getContents());
32
+ $this->assertSame(strlen($boundary) + 6, $b->getSize());
33
+ }
34
+
35
+ /**
36
+ * @expectedException \InvalidArgumentException
37
+ */
38
+ public function testValidatesFilesArrayElement()
39
+ {
40
+ new MultipartStream([['foo' => 'bar']]);
41
+ }
42
+
43
+ /**
44
+ * @expectedException \InvalidArgumentException
45
+ */
46
+ public function testEnsuresFileHasName()
47
+ {
48
+ new MultipartStream([['contents' => 'bar']]);
49
+ }
50
+
51
+ public function testSerializesFields()
52
+ {
53
+ $b = new MultipartStream([
54
+ [
55
+ 'name' => 'foo',
56
+ 'contents' => 'bar'
57
+ ],
58
+ [
59
+ 'name' => 'baz',
60
+ 'contents' => 'bam'
61
+ ]
62
+ ], 'boundary');
63
+ $this->assertEquals(
64
+ "--boundary\r\nContent-Disposition: form-data; name=\"foo\"\r\nContent-Length: 3\r\n\r\n"
65
+ . "bar\r\n--boundary\r\nContent-Disposition: form-data; name=\"baz\"\r\nContent-Length: 3"
66
+ . "\r\n\r\nbam\r\n--boundary--\r\n", (string) $b);
67
+ }
68
+
69
+ public function testSerializesNonStringFields()
70
+ {
71
+ $b = new MultipartStream([
72
+ [
73
+ 'name' => 'int',
74
+ 'contents' => (int) 1
75
+ ],
76
+ [
77
+ 'name' => 'bool',
78
+ 'contents' => (boolean) false
79
+ ],
80
+ [
81
+ 'name' => 'bool2',
82
+ 'contents' => (boolean) true
83
+ ],
84
+ [
85
+ 'name' => 'float',
86
+ 'contents' => (float) 1.1
87
+ ]
88
+ ], 'boundary');
89
+ $this->assertEquals(
90
+ "--boundary\r\nContent-Disposition: form-data; name=\"int\"\r\nContent-Length: 1\r\n\r\n"
91
+ . "1\r\n--boundary\r\nContent-Disposition: form-data; name=\"bool\"\r\n\r\n\r\n--boundary"
92
+ . "\r\nContent-Disposition: form-data; name=\"bool2\"\r\nContent-Length: 1\r\n\r\n"
93
+ . "1\r\n--boundary\r\nContent-Disposition: form-data; name=\"float\"\r\nContent-Length: 3"
94
+ . "\r\n\r\n1.1\r\n--boundary--\r\n", (string) $b);
95
+ }
96
+
97
+ public function testSerializesFiles()
98
+ {
99
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
100
+ 'getMetadata' => function () {
101
+ return '/foo/bar.txt';
102
+ }
103
+ ]);
104
+
105
+ $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [
106
+ 'getMetadata' => function () {
107
+ return '/foo/baz.jpg';
108
+ }
109
+ ]);
110
+
111
+ $f3 = Psr7\FnStream::decorate(Psr7\stream_for('bar'), [
112
+ 'getMetadata' => function () {
113
+ return '/foo/bar.gif';
114
+ }
115
+ ]);
116
+
117
+ $b = new MultipartStream([
118
+ [
119
+ 'name' => 'foo',
120
+ 'contents' => $f1
121
+ ],
122
+ [
123
+ 'name' => 'qux',
124
+ 'contents' => $f2
125
+ ],
126
+ [
127
+ 'name' => 'qux',
128
+ 'contents' => $f3
129
+ ],
130
+ ], 'boundary');
131
+
132
+ $expected = <<<EOT
133
+ --boundary
134
+ Content-Disposition: form-data; name="foo"; filename="bar.txt"
135
+ Content-Length: 3
136
+ Content-Type: text/plain
137
+
138
+ foo
139
+ --boundary
140
+ Content-Disposition: form-data; name="qux"; filename="baz.jpg"
141
+ Content-Length: 3
142
+ Content-Type: image/jpeg
143
+
144
+ baz
145
+ --boundary
146
+ Content-Disposition: form-data; name="qux"; filename="bar.gif"
147
+ Content-Length: 3
148
+ Content-Type: image/gif
149
+
150
+ bar
151
+ --boundary--
152
+
153
+ EOT;
154
+
155
+ $this->assertEquals($expected, str_replace("\r", '', $b));
156
+ }
157
+
158
+ public function testSerializesFilesWithCustomHeaders()
159
+ {
160
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
161
+ 'getMetadata' => function () {
162
+ return '/foo/bar.txt';
163
+ }
164
+ ]);
165
+
166
+ $b = new MultipartStream([
167
+ [
168
+ 'name' => 'foo',
169
+ 'contents' => $f1,
170
+ 'headers' => [
171
+ 'x-foo' => 'bar',
172
+ 'content-disposition' => 'custom'
173
+ ]
174
+ ]
175
+ ], 'boundary');
176
+
177
+ $expected = <<<EOT
178
+ --boundary
179
+ x-foo: bar
180
+ content-disposition: custom
181
+ Content-Length: 3
182
+ Content-Type: text/plain
183
+
184
+ foo
185
+ --boundary--
186
+
187
+ EOT;
188
+
189
+ $this->assertEquals($expected, str_replace("\r", '', $b));
190
+ }
191
+
192
+ public function testSerializesFilesWithCustomHeadersAndMultipleValues()
193
+ {
194
+ $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [
195
+ 'getMetadata' => function () {
196
+ return '/foo/bar.txt';
197
+ }
198
+ ]);
199
+
200
+ $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [
201
+ 'getMetadata' => function () {
202
+ return '/foo/baz.jpg';
203
+ }
204
+ ]);
205
+
206
+ $b = new MultipartStream([
207
+ [
208
+ 'name' => 'foo',
209
+ 'contents' => $f1,
210
+ 'headers' => [
211
+ 'x-foo' => 'bar',
212
+ 'content-disposition' => 'custom'
213
+ ]
214
+ ],
215
+ [
216
+ 'name' => 'foo',
217
+ 'contents' => $f2,
218
+ 'headers' => ['cOntenT-Type' => 'custom'],
219
+ ]
220
+ ], 'boundary');
221
+
222
+ $expected = <<<EOT
223
+ --boundary
224
+ x-foo: bar
225
+ content-disposition: custom
226
+ Content-Length: 3
227
+ Content-Type: text/plain
228
+
229
+ foo
230
+ --boundary
231
+ cOntenT-Type: custom
232
+ Content-Disposition: form-data; name="foo"; filename="baz.jpg"
233
+ Content-Length: 3
234
+
235
+ baz
236
+ --boundary--
237
+
238
+ EOT;
239
+
240
+ $this->assertEquals($expected, str_replace("\r", '', $b));
241
+ }
242
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\NoSeekStream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\NoSeekStream
9
+ * @covers GuzzleHttp\Psr7\StreamDecoratorTrait
10
+ */
11
+ class NoSeekStreamTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ /**
14
+ * @expectedException \RuntimeException
15
+ * @expectedExceptionMessage Cannot seek a NoSeekStream
16
+ */
17
+ public function testCannotSeek()
18
+ {
19
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
20
+ ->setMethods(['isSeekable', 'seek'])
21
+ ->getMockForAbstractClass();
22
+ $s->expects($this->never())->method('seek');
23
+ $s->expects($this->never())->method('isSeekable');
24
+ $wrapped = new NoSeekStream($s);
25
+ $this->assertFalse($wrapped->isSeekable());
26
+ $wrapped->seek(2);
27
+ }
28
+
29
+ /**
30
+ * @expectedException \RuntimeException
31
+ * @expectedExceptionMessage Cannot write to a non-writable stream
32
+ */
33
+ public function testHandlesClose()
34
+ {
35
+ $s = Psr7\stream_for('foo');
36
+ $wrapped = new NoSeekStream($s);
37
+ $wrapped->close();
38
+ $wrapped->write('foo');
39
+ }
40
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\LimitStream;
5
+ use GuzzleHttp\Psr7\PumpStream;
6
+ use GuzzleHttp\Psr7;
7
+
8
+ class PumpStreamTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ public function testHasMetadataAndSize()
11
+ {
12
+ $p = new PumpStream(function () {}, [
13
+ 'metadata' => ['foo' => 'bar'],
14
+ 'size' => 100
15
+ ]);
16
+
17
+ $this->assertEquals('bar', $p->getMetadata('foo'));
18
+ $this->assertEquals(['foo' => 'bar'], $p->getMetadata());
19
+ $this->assertEquals(100, $p->getSize());
20
+ }
21
+
22
+ public function testCanReadFromCallable()
23
+ {
24
+ $p = Psr7\stream_for(function ($size) {
25
+ return 'a';
26
+ });
27
+ $this->assertEquals('a', $p->read(1));
28
+ $this->assertEquals(1, $p->tell());
29
+ $this->assertEquals('aaaaa', $p->read(5));
30
+ $this->assertEquals(6, $p->tell());
31
+ }
32
+
33
+ public function testStoresExcessDataInBuffer()
34
+ {
35
+ $called = [];
36
+ $p = Psr7\stream_for(function ($size) use (&$called) {
37
+ $called[] = $size;
38
+ return 'abcdef';
39
+ });
40
+ $this->assertEquals('a', $p->read(1));
41
+ $this->assertEquals('b', $p->read(1));
42
+ $this->assertEquals('cdef', $p->read(4));
43
+ $this->assertEquals('abcdefabc', $p->read(9));
44
+ $this->assertEquals([1, 9, 3], $called);
45
+ }
46
+
47
+ public function testInifiniteStreamWrappedInLimitStream()
48
+ {
49
+ $p = Psr7\stream_for(function () { return 'a'; });
50
+ $s = new LimitStream($p, 5);
51
+ $this->assertEquals('aaaaa', (string) $s);
52
+ }
53
+
54
+ public function testDescribesCapabilities()
55
+ {
56
+ $p = Psr7\stream_for(function () {});
57
+ $this->assertTrue($p->isReadable());
58
+ $this->assertFalse($p->isSeekable());
59
+ $this->assertFalse($p->isWritable());
60
+ $this->assertNull($p->getSize());
61
+ $this->assertEquals('', $p->getContents());
62
+ $this->assertEquals('', (string) $p);
63
+ $p->close();
64
+ $this->assertEquals('', $p->read(10));
65
+ $this->assertTrue($p->eof());
66
+
67
+ try {
68
+ $this->assertFalse($p->write('aa'));
69
+ $this->fail();
70
+ } catch (\RuntimeException $e) {}
71
+ }
72
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/RequestTest.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\Request;
6
+ use GuzzleHttp\Psr7\Uri;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Psr7\Request
10
+ */
11
+ class RequestTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testRequestUriMayBeString()
14
+ {
15
+ $r = new Request('GET', '/');
16
+ $this->assertEquals('/', (string) $r->getUri());
17
+ }
18
+
19
+ public function testRequestUriMayBeUri()
20
+ {
21
+ $uri = new Uri('/');
22
+ $r = new Request('GET', $uri);
23
+ $this->assertSame($uri, $r->getUri());
24
+ }
25
+
26
+ /**
27
+ * @expectedException \InvalidArgumentException
28
+ */
29
+ public function testValidateRequestUri()
30
+ {
31
+ new Request('GET', '///');
32
+ }
33
+
34
+ public function testCanConstructWithBody()
35
+ {
36
+ $r = new Request('GET', '/', [], 'baz');
37
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
38
+ $this->assertEquals('baz', (string) $r->getBody());
39
+ }
40
+
41
+ public function testNullBody()
42
+ {
43
+ $r = new Request('GET', '/', [], null);
44
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
45
+ $this->assertSame('', (string) $r->getBody());
46
+ }
47
+
48
+ public function testFalseyBody()
49
+ {
50
+ $r = new Request('GET', '/', [], '0');
51
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
52
+ $this->assertSame('0', (string) $r->getBody());
53
+ }
54
+
55
+ public function testConstructorDoesNotReadStreamBody()
56
+ {
57
+ $streamIsRead = false;
58
+ $body = Psr7\FnStream::decorate(Psr7\stream_for(''), [
59
+ '__toString' => function () use (&$streamIsRead) {
60
+ $streamIsRead = true;
61
+ return '';
62
+ }
63
+ ]);
64
+
65
+ $r = new Request('GET', '/', [], $body);
66
+ $this->assertFalse($streamIsRead);
67
+ $this->assertSame($body, $r->getBody());
68
+ }
69
+
70
+ public function testCapitalizesMethod()
71
+ {
72
+ $r = new Request('get', '/');
73
+ $this->assertEquals('GET', $r->getMethod());
74
+ }
75
+
76
+ public function testCapitalizesWithMethod()
77
+ {
78
+ $r = new Request('GET', '/');
79
+ $this->assertEquals('PUT', $r->withMethod('put')->getMethod());
80
+ }
81
+
82
+ public function testWithUri()
83
+ {
84
+ $r1 = new Request('GET', '/');
85
+ $u1 = $r1->getUri();
86
+ $u2 = new Uri('http://www.example.com');
87
+ $r2 = $r1->withUri($u2);
88
+ $this->assertNotSame($r1, $r2);
89
+ $this->assertSame($u2, $r2->getUri());
90
+ $this->assertSame($u1, $r1->getUri());
91
+ }
92
+
93
+ public function testSameInstanceWhenSameUri()
94
+ {
95
+ $r1 = new Request('GET', 'http://foo.com');
96
+ $r2 = $r1->withUri($r1->getUri());
97
+ $this->assertSame($r1, $r2);
98
+ }
99
+
100
+ public function testWithRequestTarget()
101
+ {
102
+ $r1 = new Request('GET', '/');
103
+ $r2 = $r1->withRequestTarget('*');
104
+ $this->assertEquals('*', $r2->getRequestTarget());
105
+ $this->assertEquals('/', $r1->getRequestTarget());
106
+ }
107
+
108
+ /**
109
+ * @expectedException \InvalidArgumentException
110
+ */
111
+ public function testRequestTargetDoesNotAllowSpaces()
112
+ {
113
+ $r1 = new Request('GET', '/');
114
+ $r1->withRequestTarget('/foo bar');
115
+ }
116
+
117
+ public function testRequestTargetDefaultsToSlash()
118
+ {
119
+ $r1 = new Request('GET', '');
120
+ $this->assertEquals('/', $r1->getRequestTarget());
121
+ $r2 = new Request('GET', '*');
122
+ $this->assertEquals('*', $r2->getRequestTarget());
123
+ $r3 = new Request('GET', 'http://foo.com/bar baz/');
124
+ $this->assertEquals('/bar%20baz/', $r3->getRequestTarget());
125
+ }
126
+
127
+ public function testBuildsRequestTarget()
128
+ {
129
+ $r1 = new Request('GET', 'http://foo.com/baz?bar=bam');
130
+ $this->assertEquals('/baz?bar=bam', $r1->getRequestTarget());
131
+ }
132
+
133
+ public function testBuildsRequestTargetWithFalseyQuery()
134
+ {
135
+ $r1 = new Request('GET', 'http://foo.com/baz?0');
136
+ $this->assertEquals('/baz?0', $r1->getRequestTarget());
137
+ }
138
+
139
+ public function testHostIsAddedFirst()
140
+ {
141
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Foo' => 'Bar']);
142
+ $this->assertEquals([
143
+ 'Host' => ['foo.com'],
144
+ 'Foo' => ['Bar']
145
+ ], $r->getHeaders());
146
+ }
147
+
148
+ public function testCanGetHeaderAsCsv()
149
+ {
150
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', [
151
+ 'Foo' => ['a', 'b', 'c']
152
+ ]);
153
+ $this->assertEquals('a, b, c', $r->getHeaderLine('Foo'));
154
+ $this->assertEquals('', $r->getHeaderLine('Bar'));
155
+ }
156
+
157
+ public function testHostIsNotOverwrittenWhenPreservingHost()
158
+ {
159
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Host' => 'a.com']);
160
+ $this->assertEquals(['Host' => ['a.com']], $r->getHeaders());
161
+ $r2 = $r->withUri(new Uri('http://www.foo.com/bar'), true);
162
+ $this->assertEquals('a.com', $r2->getHeaderLine('Host'));
163
+ }
164
+
165
+ public function testOverridesHostWithUri()
166
+ {
167
+ $r = new Request('GET', 'http://foo.com/baz?bar=bam');
168
+ $this->assertEquals(['Host' => ['foo.com']], $r->getHeaders());
169
+ $r2 = $r->withUri(new Uri('http://www.baz.com/bar'));
170
+ $this->assertEquals('www.baz.com', $r2->getHeaderLine('Host'));
171
+ }
172
+
173
+ public function testAggregatesHeaders()
174
+ {
175
+ $r = new Request('GET', '', [
176
+ 'ZOO' => 'zoobar',
177
+ 'zoo' => ['foobar', 'zoobar']
178
+ ]);
179
+ $this->assertEquals(['ZOO' => ['zoobar', 'foobar', 'zoobar']], $r->getHeaders());
180
+ $this->assertEquals('zoobar, foobar, zoobar', $r->getHeaderLine('zoo'));
181
+ }
182
+
183
+ public function testAddsPortToHeader()
184
+ {
185
+ $r = new Request('GET', 'http://foo.com:8124/bar');
186
+ $this->assertEquals('foo.com:8124', $r->getHeaderLine('host'));
187
+ }
188
+
189
+ public function testAddsPortToHeaderAndReplacePreviousPort()
190
+ {
191
+ $r = new Request('GET', 'http://foo.com:8124/bar');
192
+ $r = $r->withUri(new Uri('http://foo.com:8125/bar'));
193
+ $this->assertEquals('foo.com:8125', $r->getHeaderLine('host'));
194
+ }
195
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/ResponseTest.php ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7;
5
+ use GuzzleHttp\Psr7\Response;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\MessageTrait
9
+ * @covers GuzzleHttp\Psr7\Response
10
+ */
11
+ class ResponseTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testDefaultConstructor()
14
+ {
15
+ $r = new Response();
16
+ $this->assertSame(200, $r->getStatusCode());
17
+ $this->assertSame('1.1', $r->getProtocolVersion());
18
+ $this->assertSame('OK', $r->getReasonPhrase());
19
+ $this->assertSame([], $r->getHeaders());
20
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
21
+ $this->assertSame('', (string) $r->getBody());
22
+ }
23
+
24
+ public function testCanConstructWithStatusCode()
25
+ {
26
+ $r = new Response(404);
27
+ $this->assertSame(404, $r->getStatusCode());
28
+ $this->assertSame('Not Found', $r->getReasonPhrase());
29
+ }
30
+
31
+ public function testConstructorDoesNotReadStreamBody()
32
+ {
33
+ $streamIsRead = false;
34
+ $body = Psr7\FnStream::decorate(Psr7\stream_for(''), [
35
+ '__toString' => function () use (&$streamIsRead) {
36
+ $streamIsRead = true;
37
+ return '';
38
+ }
39
+ ]);
40
+
41
+ $r = new Response(200, [], $body);
42
+ $this->assertFalse($streamIsRead);
43
+ $this->assertSame($body, $r->getBody());
44
+ }
45
+
46
+ public function testStatusCanBeNumericString()
47
+ {
48
+ $r = new Response('404');
49
+ $r2 = $r->withStatus('201');
50
+ $this->assertSame(404, $r->getStatusCode());
51
+ $this->assertSame('Not Found', $r->getReasonPhrase());
52
+ $this->assertSame(201, $r2->getStatusCode());
53
+ $this->assertSame('Created', $r2->getReasonPhrase());
54
+ }
55
+
56
+ public function testCanConstructWithHeaders()
57
+ {
58
+ $r = new Response(200, ['Foo' => 'Bar']);
59
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
60
+ $this->assertSame('Bar', $r->getHeaderLine('Foo'));
61
+ $this->assertSame(['Bar'], $r->getHeader('Foo'));
62
+ }
63
+
64
+ public function testCanConstructWithHeadersAsArray()
65
+ {
66
+ $r = new Response(200, [
67
+ 'Foo' => ['baz', 'bar']
68
+ ]);
69
+ $this->assertSame(['Foo' => ['baz', 'bar']], $r->getHeaders());
70
+ $this->assertSame('baz, bar', $r->getHeaderLine('Foo'));
71
+ $this->assertSame(['baz', 'bar'], $r->getHeader('Foo'));
72
+ }
73
+
74
+ public function testCanConstructWithBody()
75
+ {
76
+ $r = new Response(200, [], 'baz');
77
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
78
+ $this->assertSame('baz', (string) $r->getBody());
79
+ }
80
+
81
+ public function testNullBody()
82
+ {
83
+ $r = new Response(200, [], null);
84
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
85
+ $this->assertSame('', (string) $r->getBody());
86
+ }
87
+
88
+ public function testFalseyBody()
89
+ {
90
+ $r = new Response(200, [], '0');
91
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
92
+ $this->assertSame('0', (string) $r->getBody());
93
+ }
94
+
95
+ public function testCanConstructWithReason()
96
+ {
97
+ $r = new Response(200, [], null, '1.1', 'bar');
98
+ $this->assertSame('bar', $r->getReasonPhrase());
99
+
100
+ $r = new Response(200, [], null, '1.1', '0');
101
+ $this->assertSame('0', $r->getReasonPhrase(), 'Falsey reason works');
102
+ }
103
+
104
+ public function testCanConstructWithProtocolVersion()
105
+ {
106
+ $r = new Response(200, [], null, '1000');
107
+ $this->assertSame('1000', $r->getProtocolVersion());
108
+ }
109
+
110
+ public function testWithStatusCodeAndNoReason()
111
+ {
112
+ $r = (new Response())->withStatus(201);
113
+ $this->assertSame(201, $r->getStatusCode());
114
+ $this->assertSame('Created', $r->getReasonPhrase());
115
+ }
116
+
117
+ public function testWithStatusCodeAndReason()
118
+ {
119
+ $r = (new Response())->withStatus(201, 'Foo');
120
+ $this->assertSame(201, $r->getStatusCode());
121
+ $this->assertSame('Foo', $r->getReasonPhrase());
122
+
123
+ $r = (new Response())->withStatus(201, '0');
124
+ $this->assertSame(201, $r->getStatusCode());
125
+ $this->assertSame('0', $r->getReasonPhrase(), 'Falsey reason works');
126
+ }
127
+
128
+ public function testWithProtocolVersion()
129
+ {
130
+ $r = (new Response())->withProtocolVersion('1000');
131
+ $this->assertSame('1000', $r->getProtocolVersion());
132
+ }
133
+
134
+ public function testSameInstanceWhenSameProtocol()
135
+ {
136
+ $r = new Response();
137
+ $this->assertSame($r, $r->withProtocolVersion('1.1'));
138
+ }
139
+
140
+ public function testWithBody()
141
+ {
142
+ $b = Psr7\stream_for('0');
143
+ $r = (new Response())->withBody($b);
144
+ $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
145
+ $this->assertSame('0', (string) $r->getBody());
146
+ }
147
+
148
+ public function testSameInstanceWhenSameBody()
149
+ {
150
+ $r = new Response();
151
+ $b = $r->getBody();
152
+ $this->assertSame($r, $r->withBody($b));
153
+ }
154
+
155
+ public function testWithHeader()
156
+ {
157
+ $r = new Response(200, ['Foo' => 'Bar']);
158
+ $r2 = $r->withHeader('baZ', 'Bam');
159
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
160
+ $this->assertSame(['Foo' => ['Bar'], 'baZ' => ['Bam']], $r2->getHeaders());
161
+ $this->assertSame('Bam', $r2->getHeaderLine('baz'));
162
+ $this->assertSame(['Bam'], $r2->getHeader('baz'));
163
+ }
164
+
165
+ public function testWithHeaderAsArray()
166
+ {
167
+ $r = new Response(200, ['Foo' => 'Bar']);
168
+ $r2 = $r->withHeader('baZ', ['Bam', 'Bar']);
169
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
170
+ $this->assertSame(['Foo' => ['Bar'], 'baZ' => ['Bam', 'Bar']], $r2->getHeaders());
171
+ $this->assertSame('Bam, Bar', $r2->getHeaderLine('baz'));
172
+ $this->assertSame(['Bam', 'Bar'], $r2->getHeader('baz'));
173
+ }
174
+
175
+ public function testWithHeaderReplacesDifferentCase()
176
+ {
177
+ $r = new Response(200, ['Foo' => 'Bar']);
178
+ $r2 = $r->withHeader('foO', 'Bam');
179
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
180
+ $this->assertSame(['foO' => ['Bam']], $r2->getHeaders());
181
+ $this->assertSame('Bam', $r2->getHeaderLine('foo'));
182
+ $this->assertSame(['Bam'], $r2->getHeader('foo'));
183
+ }
184
+
185
+ public function testWithAddedHeader()
186
+ {
187
+ $r = new Response(200, ['Foo' => 'Bar']);
188
+ $r2 = $r->withAddedHeader('foO', 'Baz');
189
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
190
+ $this->assertSame(['Foo' => ['Bar', 'Baz']], $r2->getHeaders());
191
+ $this->assertSame('Bar, Baz', $r2->getHeaderLine('foo'));
192
+ $this->assertSame(['Bar', 'Baz'], $r2->getHeader('foo'));
193
+ }
194
+
195
+ public function testWithAddedHeaderAsArray()
196
+ {
197
+ $r = new Response(200, ['Foo' => 'Bar']);
198
+ $r2 = $r->withAddedHeader('foO', ['Baz', 'Bam']);
199
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
200
+ $this->assertSame(['Foo' => ['Bar', 'Baz', 'Bam']], $r2->getHeaders());
201
+ $this->assertSame('Bar, Baz, Bam', $r2->getHeaderLine('foo'));
202
+ $this->assertSame(['Bar', 'Baz', 'Bam'], $r2->getHeader('foo'));
203
+ }
204
+
205
+ public function testWithAddedHeaderThatDoesNotExist()
206
+ {
207
+ $r = new Response(200, ['Foo' => 'Bar']);
208
+ $r2 = $r->withAddedHeader('nEw', 'Baz');
209
+ $this->assertSame(['Foo' => ['Bar']], $r->getHeaders());
210
+ $this->assertSame(['Foo' => ['Bar'], 'nEw' => ['Baz']], $r2->getHeaders());
211
+ $this->assertSame('Baz', $r2->getHeaderLine('new'));
212
+ $this->assertSame(['Baz'], $r2->getHeader('new'));
213
+ }
214
+
215
+ public function testWithoutHeaderThatExists()
216
+ {
217
+ $r = new Response(200, ['Foo' => 'Bar', 'Baz' => 'Bam']);
218
+ $r2 = $r->withoutHeader('foO');
219
+ $this->assertTrue($r->hasHeader('foo'));
220
+ $this->assertSame(['Foo' => ['Bar'], 'Baz' => ['Bam']], $r->getHeaders());
221
+ $this->assertFalse($r2->hasHeader('foo'));
222
+ $this->assertSame(['Baz' => ['Bam']], $r2->getHeaders());
223
+ }
224
+
225
+ public function testWithoutHeaderThatDoesNotExist()
226
+ {
227
+ $r = new Response(200, ['Baz' => 'Bam']);
228
+ $r2 = $r->withoutHeader('foO');
229
+ $this->assertSame($r, $r2);
230
+ $this->assertFalse($r2->hasHeader('foo'));
231
+ $this->assertSame(['Baz' => ['Bam']], $r2->getHeaders());
232
+ }
233
+
234
+ public function testSameInstanceWhenRemovingMissingHeader()
235
+ {
236
+ $r = new Response();
237
+ $this->assertSame($r, $r->withoutHeader('foo'));
238
+ }
239
+
240
+ public function testHeaderValuesAreTrimmed()
241
+ {
242
+ $r1 = new Response(200, ['OWS' => " \t \tFoo\t \t "]);
243
+ $r2 = (new Response())->withHeader('OWS', " \t \tFoo\t \t ");
244
+ $r3 = (new Response())->withAddedHeader('OWS', " \t \tFoo\t \t ");;
245
+
246
+ foreach ([$r1, $r2, $r3] as $r) {
247
+ $this->assertSame(['OWS' => ['Foo']], $r->getHeaders());
248
+ $this->assertSame('Foo', $r->getHeaderLine('OWS'));
249
+ $this->assertSame(['Foo'], $r->getHeader('OWS'));
250
+ }
251
+ }
252
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\ServerRequest;
5
+ use GuzzleHttp\Psr7\UploadedFile;
6
+ use GuzzleHttp\Psr7\Uri;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Psr7\ServerRequest
10
+ */
11
+ class ServerRequestTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function dataNormalizeFiles()
14
+ {
15
+ return [
16
+ 'Single file' => [
17
+ [
18
+ 'file' => [
19
+ 'name' => 'MyFile.txt',
20
+ 'type' => 'text/plain',
21
+ 'tmp_name' => '/tmp/php/php1h4j1o',
22
+ 'error' => '0',
23
+ 'size' => '123'
24
+ ]
25
+ ],
26
+ [
27
+ 'file' => new UploadedFile(
28
+ '/tmp/php/php1h4j1o',
29
+ 123,
30
+ UPLOAD_ERR_OK,
31
+ 'MyFile.txt',
32
+ 'text/plain'
33
+ )
34
+ ]
35
+ ],
36
+ 'Empty file' => [
37
+ [
38
+ 'image_file' => [
39
+ 'name' => '',
40
+ 'type' => '',
41
+ 'tmp_name' => '',
42
+ 'error' => '4',
43
+ 'size' => '0'
44
+ ]
45
+ ],
46
+ [
47
+ 'image_file' => new UploadedFile(
48
+ '',
49
+ 0,
50
+ UPLOAD_ERR_NO_FILE,
51
+ '',
52
+ ''
53
+ )
54
+ ]
55
+ ],
56
+ 'Already Converted' => [
57
+ [
58
+ 'file' => new UploadedFile(
59
+ '/tmp/php/php1h4j1o',
60
+ 123,
61
+ UPLOAD_ERR_OK,
62
+ 'MyFile.txt',
63
+ 'text/plain'
64
+ )
65
+ ],
66
+ [
67
+ 'file' => new UploadedFile(
68
+ '/tmp/php/php1h4j1o',
69
+ 123,
70
+ UPLOAD_ERR_OK,
71
+ 'MyFile.txt',
72
+ 'text/plain'
73
+ )
74
+ ]
75
+ ],
76
+ 'Already Converted array' => [
77
+ [
78
+ 'file' => [
79
+ new UploadedFile(
80
+ '/tmp/php/php1h4j1o',
81
+ 123,
82
+ UPLOAD_ERR_OK,
83
+ 'MyFile.txt',
84
+ 'text/plain'
85
+ ),
86
+ new UploadedFile(
87
+ '',
88
+ 0,
89
+ UPLOAD_ERR_NO_FILE,
90
+ '',
91
+ ''
92
+ )
93
+ ],
94
+ ],
95
+ [
96
+ 'file' => [
97
+ new UploadedFile(
98
+ '/tmp/php/php1h4j1o',
99
+ 123,
100
+ UPLOAD_ERR_OK,
101
+ 'MyFile.txt',
102
+ 'text/plain'
103
+ ),
104
+ new UploadedFile(
105
+ '',
106
+ 0,
107
+ UPLOAD_ERR_NO_FILE,
108
+ '',
109
+ ''
110
+ )
111
+ ],
112
+ ]
113
+ ],
114
+ 'Multiple files' => [
115
+ [
116
+ 'text_file' => [
117
+ 'name' => 'MyFile.txt',
118
+ 'type' => 'text/plain',
119
+ 'tmp_name' => '/tmp/php/php1h4j1o',
120
+ 'error' => '0',
121
+ 'size' => '123'
122
+ ],
123
+ 'image_file' => [
124
+ 'name' => '',
125
+ 'type' => '',
126
+ 'tmp_name' => '',
127
+ 'error' => '4',
128
+ 'size' => '0'
129
+ ]
130
+ ],
131
+ [
132
+ 'text_file' => new UploadedFile(
133
+ '/tmp/php/php1h4j1o',
134
+ 123,
135
+ UPLOAD_ERR_OK,
136
+ 'MyFile.txt',
137
+ 'text/plain'
138
+ ),
139
+ 'image_file' => new UploadedFile(
140
+ '',
141
+ 0,
142
+ UPLOAD_ERR_NO_FILE,
143
+ '',
144
+ ''
145
+ )
146
+ ]
147
+ ],
148
+ 'Nested files' => [
149
+ [
150
+ 'file' => [
151
+ 'name' => [
152
+ 0 => 'MyFile.txt',
153
+ 1 => 'Image.png',
154
+ ],
155
+ 'type' => [
156
+ 0 => 'text/plain',
157
+ 1 => 'image/png',
158
+ ],
159
+ 'tmp_name' => [
160
+ 0 => '/tmp/php/hp9hskjhf',
161
+ 1 => '/tmp/php/php1h4j1o',
162
+ ],
163
+ 'error' => [
164
+ 0 => '0',
165
+ 1 => '0',
166
+ ],
167
+ 'size' => [
168
+ 0 => '123',
169
+ 1 => '7349',
170
+ ],
171
+ ],
172
+ 'nested' => [
173
+ 'name' => [
174
+ 'other' => 'Flag.txt',
175
+ 'test' => [
176
+ 0 => 'Stuff.txt',
177
+ 1 => '',
178
+ ],
179
+ ],
180
+ 'type' => [
181
+ 'other' => 'text/plain',
182
+ 'test' => [
183
+ 0 => 'text/plain',
184
+ 1 => '',
185
+ ],
186
+ ],
187
+ 'tmp_name' => [
188
+ 'other' => '/tmp/php/hp9hskjhf',
189
+ 'test' => [
190
+ 0 => '/tmp/php/asifu2gp3',
191
+ 1 => '',
192
+ ],
193
+ ],
194
+ 'error' => [
195
+ 'other' => '0',
196
+ 'test' => [
197
+ 0 => '0',
198
+ 1 => '4',
199
+ ],
200
+ ],
201
+ 'size' => [
202
+ 'other' => '421',
203
+ 'test' => [
204
+ 0 => '32',
205
+ 1 => '0',
206
+ ]
207
+ ]
208
+ ],
209
+ ],
210
+ [
211
+ 'file' => [
212
+ 0 => new UploadedFile(
213
+ '/tmp/php/hp9hskjhf',
214
+ 123,
215
+ UPLOAD_ERR_OK,
216
+ 'MyFile.txt',
217
+ 'text/plain'
218
+ ),
219
+ 1 => new UploadedFile(
220
+ '/tmp/php/php1h4j1o',
221
+ 7349,
222
+ UPLOAD_ERR_OK,
223
+ 'Image.png',
224
+ 'image/png'
225
+ ),
226
+ ],
227
+ 'nested' => [
228
+ 'other' => new UploadedFile(
229
+ '/tmp/php/hp9hskjhf',
230
+ 421,
231
+ UPLOAD_ERR_OK,
232
+ 'Flag.txt',
233
+ 'text/plain'
234
+ ),
235
+ 'test' => [
236
+ 0 => new UploadedFile(
237
+ '/tmp/php/asifu2gp3',
238
+ 32,
239
+ UPLOAD_ERR_OK,
240
+ 'Stuff.txt',
241
+ 'text/plain'
242
+ ),
243
+ 1 => new UploadedFile(
244
+ '',
245
+ 0,
246
+ UPLOAD_ERR_NO_FILE,
247
+ '',
248
+ ''
249
+ ),
250
+ ]
251
+ ]
252
+ ]
253
+ ]
254
+ ];
255
+ }
256
+
257
+ /**
258
+ * @dataProvider dataNormalizeFiles
259
+ */
260
+ public function testNormalizeFiles($files, $expected)
261
+ {
262
+ $result = ServerRequest::normalizeFiles($files);
263
+
264
+ $this->assertEquals($expected, $result);
265
+ }
266
+
267
+ public function testNormalizeFilesRaisesException()
268
+ {
269
+ $this->setExpectedException('InvalidArgumentException', 'Invalid value in files specification');
270
+
271
+ ServerRequest::normalizeFiles(['test' => 'something']);
272
+ }
273
+
274
+ public function dataGetUriFromGlobals()
275
+ {
276
+ $server = [
277
+ 'PHP_SELF' => '/blog/article.php',
278
+ 'GATEWAY_INTERFACE' => 'CGI/1.1',
279
+ 'SERVER_ADDR' => 'Server IP: 217.112.82.20',
280
+ 'SERVER_NAME' => 'www.blakesimpson.co.uk',
281
+ 'SERVER_SOFTWARE' => 'Apache/2.2.15 (Win32) JRun/4.0 PHP/5.2.13',
282
+ 'SERVER_PROTOCOL' => 'HTTP/1.0',
283
+ 'REQUEST_METHOD' => 'POST',
284
+ 'REQUEST_TIME' => 'Request start time: 1280149029',
285
+ 'QUERY_STRING' => 'id=10&user=foo',
286
+ 'DOCUMENT_ROOT' => '/path/to/your/server/root/',
287
+ 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
288
+ 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
289
+ 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
290
+ 'HTTP_ACCEPT_LANGUAGE' => 'en-gb,en;q=0.5',
291
+ 'HTTP_CONNECTION' => 'keep-alive',
292
+ 'HTTP_HOST' => 'www.blakesimpson.co.uk',
293
+ 'HTTP_REFERER' => 'http://previous.url.com',
294
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729)',
295
+ 'HTTPS' => '1',
296
+ 'REMOTE_ADDR' => '193.60.168.69',
297
+ 'REMOTE_HOST' => 'Client server\'s host name',
298
+ 'REMOTE_PORT' => '5390',
299
+ 'SCRIPT_FILENAME' => '/path/to/this/script.php',
300
+ 'SERVER_ADMIN' => 'webmaster@blakesimpson.co.uk',
301
+ 'SERVER_PORT' => '80',
302
+ 'SERVER_SIGNATURE' => 'Version signature: 5.123',
303
+ 'SCRIPT_NAME' => '/blog/article.php',
304
+ 'REQUEST_URI' => '/blog/article.php?id=10&user=foo',
305
+ ];
306
+
307
+ return [
308
+ 'Normal request' => [
309
+ 'http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo',
310
+ $server,
311
+ ],
312
+ 'Secure request' => [
313
+ 'https://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo',
314
+ array_merge($server, ['HTTPS' => 'on', 'SERVER_PORT' => '443']),
315
+ ],
316
+ 'HTTP_HOST missing' => [
317
+ 'http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo',
318
+ array_merge($server, ['HTTP_HOST' => null]),
319
+ ],
320
+ 'No query String' => [
321
+ 'http://www.blakesimpson.co.uk/blog/article.php',
322
+ array_merge($server, ['REQUEST_URI' => '/blog/article.php', 'QUERY_STRING' => '']),
323
+ ],
324
+ 'Different port' => [
325
+ 'http://www.blakesimpson.co.uk:8324/blog/article.php?id=10&user=foo',
326
+ array_merge($server, ['SERVER_PORT' => '8324']),
327
+ ],
328
+ 'Empty server variable' => [
329
+ '',
330
+ [],
331
+ ],
332
+ ];
333
+ }
334
+
335
+ /**
336
+ * @dataProvider dataGetUriFromGlobals
337
+ */
338
+ public function testGetUriFromGlobals($expected, $serverParams)
339
+ {
340
+ $_SERVER = $serverParams;
341
+
342
+ $this->assertEquals(new Uri($expected), ServerRequest::getUriFromGlobals());
343
+ }
344
+
345
+ public function testFromGlobals()
346
+ {
347
+ $_SERVER = [
348
+ 'PHP_SELF' => '/blog/article.php',
349
+ 'GATEWAY_INTERFACE' => 'CGI/1.1',
350
+ 'SERVER_ADDR' => 'Server IP: 217.112.82.20',
351
+ 'SERVER_NAME' => 'www.blakesimpson.co.uk',
352
+ 'SERVER_SOFTWARE' => 'Apache/2.2.15 (Win32) JRun/4.0 PHP/5.2.13',
353
+ 'SERVER_PROTOCOL' => 'HTTP/1.0',
354
+ 'REQUEST_METHOD' => 'POST',
355
+ 'REQUEST_TIME' => 'Request start time: 1280149029',
356
+ 'QUERY_STRING' => 'id=10&user=foo',
357
+ 'DOCUMENT_ROOT' => '/path/to/your/server/root/',
358
+ 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
359
+ 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
360
+ 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
361
+ 'HTTP_ACCEPT_LANGUAGE' => 'en-gb,en;q=0.5',
362
+ 'HTTP_CONNECTION' => 'keep-alive',
363
+ 'HTTP_HOST' => 'www.blakesimpson.co.uk',
364
+ 'HTTP_REFERER' => 'http://previous.url.com',
365
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729)',
366
+ 'HTTPS' => '1',
367
+ 'REMOTE_ADDR' => '193.60.168.69',
368
+ 'REMOTE_HOST' => 'Client server\'s host name',
369
+ 'REMOTE_PORT' => '5390',
370
+ 'SCRIPT_FILENAME' => '/path/to/this/script.php',
371
+ 'SERVER_ADMIN' => 'webmaster@blakesimpson.co.uk',
372
+ 'SERVER_PORT' => '80',
373
+ 'SERVER_SIGNATURE' => 'Version signature: 5.123',
374
+ 'SCRIPT_NAME' => '/blog/article.php',
375
+ 'REQUEST_URI' => '/blog/article.php?id=10&user=foo',
376
+ ];
377
+
378
+ $_COOKIE = [
379
+ 'logged-in' => 'yes!'
380
+ ];
381
+
382
+ $_POST = [
383
+ 'name' => 'Pesho',
384
+ 'email' => 'pesho@example.com',
385
+ ];
386
+
387
+ $_GET = [
388
+ 'id' => 10,
389
+ 'user' => 'foo',
390
+ ];
391
+
392
+ $_FILES = [
393
+ 'file' => [
394
+ 'name' => 'MyFile.txt',
395
+ 'type' => 'text/plain',
396
+ 'tmp_name' => '/tmp/php/php1h4j1o',
397
+ 'error' => UPLOAD_ERR_OK,
398
+ 'size' => 123,
399
+ ]
400
+ ];
401
+
402
+ $server = ServerRequest::fromGlobals();
403
+
404
+ $this->assertEquals('POST', $server->getMethod());
405
+ $this->assertEquals(['Host' => ['www.blakesimpson.co.uk']], $server->getHeaders());
406
+ $this->assertEquals('', (string) $server->getBody());
407
+ $this->assertEquals('1.0', $server->getProtocolVersion());
408
+ $this->assertEquals($_COOKIE, $server->getCookieParams());
409
+ $this->assertEquals($_POST, $server->getParsedBody());
410
+ $this->assertEquals($_GET, $server->getQueryParams());
411
+
412
+ $this->assertEquals(
413
+ new Uri('http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo'),
414
+ $server->getUri()
415
+ );
416
+
417
+ $expectedFiles = [
418
+ 'file' => new UploadedFile(
419
+ '/tmp/php/php1h4j1o',
420
+ 123,
421
+ UPLOAD_ERR_OK,
422
+ 'MyFile.txt',
423
+ 'text/plain'
424
+ ),
425
+ ];
426
+
427
+ $this->assertEquals($expectedFiles, $server->getUploadedFiles());
428
+ }
429
+
430
+ public function testUploadedFiles()
431
+ {
432
+ $request1 = new ServerRequest('GET', '/');
433
+
434
+ $files = [
435
+ 'file' => new UploadedFile('test', 123, UPLOAD_ERR_OK)
436
+ ];
437
+
438
+ $request2 = $request1->withUploadedFiles($files);
439
+
440
+ $this->assertNotSame($request2, $request1);
441
+ $this->assertSame([], $request1->getUploadedFiles());
442
+ $this->assertSame($files, $request2->getUploadedFiles());
443
+ }
444
+
445
+ public function testServerParams()
446
+ {
447
+ $params = ['name' => 'value'];
448
+
449
+ $request = new ServerRequest('GET', '/', [], null, '1.1', $params);
450
+ $this->assertSame($params, $request->getServerParams());
451
+ }
452
+
453
+ public function testCookieParams()
454
+ {
455
+ $request1 = new ServerRequest('GET', '/');
456
+
457
+ $params = ['name' => 'value'];
458
+
459
+ $request2 = $request1->withCookieParams($params);
460
+
461
+ $this->assertNotSame($request2, $request1);
462
+ $this->assertEmpty($request1->getCookieParams());
463
+ $this->assertSame($params, $request2->getCookieParams());
464
+ }
465
+
466
+ public function testQueryParams()
467
+ {
468
+ $request1 = new ServerRequest('GET', '/');
469
+
470
+ $params = ['name' => 'value'];
471
+
472
+ $request2 = $request1->withQueryParams($params);
473
+
474
+ $this->assertNotSame($request2, $request1);
475
+ $this->assertEmpty($request1->getQueryParams());
476
+ $this->assertSame($params, $request2->getQueryParams());
477
+ }
478
+
479
+ public function testParsedBody()
480
+ {
481
+ $request1 = new ServerRequest('GET', '/');
482
+
483
+ $params = ['name' => 'value'];
484
+
485
+ $request2 = $request1->withParsedBody($params);
486
+
487
+ $this->assertNotSame($request2, $request1);
488
+ $this->assertEmpty($request1->getParsedBody());
489
+ $this->assertSame($params, $request2->getParsedBody());
490
+ }
491
+
492
+ public function testAttributes()
493
+ {
494
+ $request1 = new ServerRequest('GET', '/');
495
+
496
+ $request2 = $request1->withAttribute('name', 'value');
497
+ $request3 = $request2->withAttribute('other', 'otherValue');
498
+ $request4 = $request3->withoutAttribute('other');
499
+ $request5 = $request3->withoutAttribute('unknown');
500
+
501
+ $this->assertNotSame($request2, $request1);
502
+ $this->assertNotSame($request3, $request2);
503
+ $this->assertNotSame($request4, $request3);
504
+ $this->assertNotSame($request5, $request4);
505
+
506
+ $this->assertEmpty($request1->getAttributes());
507
+ $this->assertEmpty($request1->getAttribute('name'));
508
+ $this->assertEquals(
509
+ 'something',
510
+ $request1->getAttribute('name', 'something'),
511
+ 'Should return the default value'
512
+ );
513
+
514
+ $this->assertEquals('value', $request2->getAttribute('name'));
515
+ $this->assertEquals(['name' => 'value'], $request2->getAttributes());
516
+ $this->assertEquals(['name' => 'value', 'other' => 'otherValue'], $request3->getAttributes());
517
+ $this->assertEquals(['name' => 'value'], $request4->getAttributes());
518
+ }
519
+
520
+ public function testNullAttribute()
521
+ {
522
+ $request = (new ServerRequest('GET', '/'))->withAttribute('name', null);
523
+
524
+ $this->assertSame(['name' => null], $request->getAttributes());
525
+ $this->assertNull($request->getAttribute('name', 'different-default'));
526
+
527
+ $requestWithoutAttribute = $request->withoutAttribute('name');
528
+
529
+ $this->assertSame([], $requestWithoutAttribute->getAttributes());
530
+ $this->assertSame('different-default', $requestWithoutAttribute->getAttribute('name', 'different-default'));
531
+ }
532
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use Psr\Http\Message\StreamInterface;
5
+ use GuzzleHttp\Psr7;
6
+ use GuzzleHttp\Psr7\StreamDecoratorTrait;
7
+
8
+ class Str implements StreamInterface
9
+ {
10
+ use StreamDecoratorTrait;
11
+ }
12
+
13
+ /**
14
+ * @covers GuzzleHttp\Psr7\StreamDecoratorTrait
15
+ */
16
+ class StreamDecoratorTraitTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ private $a;
19
+ private $b;
20
+ private $c;
21
+
22
+ public function setUp()
23
+ {
24
+ $this->c = fopen('php://temp', 'r+');
25
+ fwrite($this->c, 'foo');
26
+ fseek($this->c, 0);
27
+ $this->a = Psr7\stream_for($this->c);
28
+ $this->b = new Str($this->a);
29
+ }
30
+
31
+ public function testCatchesExceptionsWhenCastingToString()
32
+ {
33
+ $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
34
+ ->setMethods(['read'])
35
+ ->getMockForAbstractClass();
36
+ $s->expects($this->once())
37
+ ->method('read')
38
+ ->will($this->throwException(new \Exception('foo')));
39
+ $msg = '';
40
+ set_error_handler(function ($errNo, $str) use (&$msg) { $msg = $str; });
41
+ echo new Str($s);
42
+ restore_error_handler();
43
+ $this->assertContains('foo', $msg);
44
+ }
45
+
46
+ public function testToString()
47
+ {
48
+ $this->assertEquals('foo', (string) $this->b);
49
+ }
50
+
51
+ public function testHasSize()
52
+ {
53
+ $this->assertEquals(3, $this->b->getSize());
54
+ }
55
+
56
+ public function testReads()
57
+ {
58
+ $this->assertEquals('foo', $this->b->read(10));
59
+ }
60
+
61
+ public function testCheckMethods()
62
+ {
63
+ $this->assertEquals($this->a->isReadable(), $this->b->isReadable());
64
+ $this->assertEquals($this->a->isWritable(), $this->b->isWritable());
65
+ $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable());
66
+ }
67
+
68
+ public function testSeeksAndTells()
69
+ {
70
+ $this->b->seek(1);
71
+ $this->assertEquals(1, $this->a->tell());
72
+ $this->assertEquals(1, $this->b->tell());
73
+ $this->b->seek(0);
74
+ $this->assertEquals(0, $this->a->tell());
75
+ $this->assertEquals(0, $this->b->tell());
76
+ $this->b->seek(0, SEEK_END);
77
+ $this->assertEquals(3, $this->a->tell());
78
+ $this->assertEquals(3, $this->b->tell());
79
+ }
80
+
81
+ public function testGetsContents()
82
+ {
83
+ $this->assertEquals('foo', $this->b->getContents());
84
+ $this->assertEquals('', $this->b->getContents());
85
+ $this->b->seek(1);
86
+ $this->assertEquals('oo', $this->b->getContents(1));
87
+ }
88
+
89
+ public function testCloses()
90
+ {
91
+ $this->b->close();
92
+ $this->assertFalse(is_resource($this->c));
93
+ }
94
+
95
+ public function testDetaches()
96
+ {
97
+ $this->b->detach();
98
+ $this->assertFalse($this->b->isReadable());
99
+ }
100
+
101
+ public function testWrapsMetadata()
102
+ {
103
+ $this->assertSame($this->b->getMetadata(), $this->a->getMetadata());
104
+ $this->assertSame($this->b->getMetadata('uri'), $this->a->getMetadata('uri'));
105
+ }
106
+
107
+ public function testWrapsWrites()
108
+ {
109
+ $this->b->seek(0, SEEK_END);
110
+ $this->b->write('foo');
111
+ $this->assertEquals('foofoo', (string) $this->a);
112
+ }
113
+
114
+ /**
115
+ * @expectedException \UnexpectedValueException
116
+ */
117
+ public function testThrowsWithInvalidGetter()
118
+ {
119
+ $this->b->foo;
120
+ }
121
+
122
+ /**
123
+ * @expectedException \BadMethodCallException
124
+ */
125
+ public function testThrowsWhenGetterNotImplemented()
126
+ {
127
+ $s = new BadStream();
128
+ $s->stream;
129
+ }
130
+ }
131
+
132
+ class BadStream
133
+ {
134
+ use StreamDecoratorTrait;
135
+
136
+ public function __construct() {}
137
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamTest.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\NoSeekStream;
5
+ use GuzzleHttp\Psr7\Stream;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\Stream
9
+ */
10
+ class StreamTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /**
13
+ * @expectedException \InvalidArgumentException
14
+ */
15
+ public function testConstructorThrowsExceptionOnInvalidArgument()
16
+ {
17
+ new Stream(true);
18
+ }
19
+
20
+ public function testConstructorInitializesProperties()
21
+ {
22
+ $handle = fopen('php://temp', 'r+');
23
+ fwrite($handle, 'data');
24
+ $stream = new Stream($handle);
25
+ $this->assertTrue($stream->isReadable());
26
+ $this->assertTrue($stream->isWritable());
27
+ $this->assertTrue($stream->isSeekable());
28
+ $this->assertEquals('php://temp', $stream->getMetadata('uri'));
29
+ $this->assertInternalType('array', $stream->getMetadata());
30
+ $this->assertEquals(4, $stream->getSize());
31
+ $this->assertFalse($stream->eof());
32
+ $stream->close();
33
+ }
34
+
35
+ public function testStreamClosesHandleOnDestruct()
36
+ {
37
+ $handle = fopen('php://temp', 'r');
38
+ $stream = new Stream($handle);
39
+ unset($stream);
40
+ $this->assertFalse(is_resource($handle));
41
+ }
42
+
43
+ public function testConvertsToString()
44
+ {
45
+ $handle = fopen('php://temp', 'w+');
46
+ fwrite($handle, 'data');
47
+ $stream = new Stream($handle);
48
+ $this->assertEquals('data', (string) $stream);
49
+ $this->assertEquals('data', (string) $stream);
50
+ $stream->close();
51
+ }
52
+
53
+ public function testGetsContents()
54
+ {
55
+ $handle = fopen('php://temp', 'w+');
56
+ fwrite($handle, 'data');
57
+ $stream = new Stream($handle);
58
+ $this->assertEquals('', $stream->getContents());
59
+ $stream->seek(0);
60
+ $this->assertEquals('data', $stream->getContents());
61
+ $this->assertEquals('', $stream->getContents());
62
+ }
63
+
64
+ public function testChecksEof()
65
+ {
66
+ $handle = fopen('php://temp', 'w+');
67
+ fwrite($handle, 'data');
68
+ $stream = new Stream($handle);
69
+ $this->assertFalse($stream->eof());
70
+ $stream->read(4);
71
+ $this->assertTrue($stream->eof());
72
+ $stream->close();
73
+ }
74
+
75
+ public function testGetSize()
76
+ {
77
+ $size = filesize(__FILE__);
78
+ $handle = fopen(__FILE__, 'r');
79
+ $stream = new Stream($handle);
80
+ $this->assertEquals($size, $stream->getSize());
81
+ // Load from cache
82
+ $this->assertEquals($size, $stream->getSize());
83
+ $stream->close();
84
+ }
85
+
86
+ public function testEnsuresSizeIsConsistent()
87
+ {
88
+ $h = fopen('php://temp', 'w+');
89
+ $this->assertEquals(3, fwrite($h, 'foo'));
90
+ $stream = new Stream($h);
91
+ $this->assertEquals(3, $stream->getSize());
92
+ $this->assertEquals(4, $stream->write('test'));
93
+ $this->assertEquals(7, $stream->getSize());
94
+ $this->assertEquals(7, $stream->getSize());
95
+ $stream->close();
96
+ }
97
+
98
+ public function testProvidesStreamPosition()
99
+ {
100
+ $handle = fopen('php://temp', 'w+');
101
+ $stream = new Stream($handle);
102
+ $this->assertEquals(0, $stream->tell());
103
+ $stream->write('foo');
104
+ $this->assertEquals(3, $stream->tell());
105
+ $stream->seek(1);
106
+ $this->assertEquals(1, $stream->tell());
107
+ $this->assertSame(ftell($handle), $stream->tell());
108
+ $stream->close();
109
+ }
110
+
111
+ public function testCanDetachStream()
112
+ {
113
+ $r = fopen('php://temp', 'w+');
114
+ $stream = new Stream($r);
115
+ $stream->write('foo');
116
+ $this->assertTrue($stream->isReadable());
117
+ $this->assertSame($r, $stream->detach());
118
+ $stream->detach();
119
+
120
+ $this->assertFalse($stream->isReadable());
121
+ $this->assertFalse($stream->isWritable());
122
+ $this->assertFalse($stream->isSeekable());
123
+
124
+ $throws = function (callable $fn) use ($stream) {
125
+ try {
126
+ $fn($stream);
127
+ $this->fail();
128
+ } catch (\Exception $e) {}
129
+ };
130
+
131
+ $throws(function ($stream) { $stream->read(10); });
132
+ $throws(function ($stream) { $stream->write('bar'); });
133
+ $throws(function ($stream) { $stream->seek(10); });
134
+ $throws(function ($stream) { $stream->tell(); });
135
+ $throws(function ($stream) { $stream->eof(); });
136
+ $throws(function ($stream) { $stream->getSize(); });
137
+ $throws(function ($stream) { $stream->getContents(); });
138
+ $this->assertSame('', (string) $stream);
139
+ $stream->close();
140
+ }
141
+
142
+ public function testCloseClearProperties()
143
+ {
144
+ $handle = fopen('php://temp', 'r+');
145
+ $stream = new Stream($handle);
146
+ $stream->close();
147
+
148
+ $this->assertFalse($stream->isSeekable());
149
+ $this->assertFalse($stream->isReadable());
150
+ $this->assertFalse($stream->isWritable());
151
+ $this->assertNull($stream->getSize());
152
+ $this->assertEmpty($stream->getMetadata());
153
+ }
154
+
155
+ public function testDoesNotThrowInToString()
156
+ {
157
+ $s = \GuzzleHttp\Psr7\stream_for('foo');
158
+ $s = new NoSeekStream($s);
159
+ $this->assertEquals('foo', (string) $s);
160
+ }
161
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\StreamWrapper;
5
+ use GuzzleHttp\Psr7;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Psr7\StreamWrapper
9
+ */
10
+ class StreamWrapperTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testResource()
13
+ {
14
+ $stream = Psr7\stream_for('foo');
15
+ $handle = StreamWrapper::getResource($stream);
16
+ $this->assertSame('foo', fread($handle, 3));
17
+ $this->assertSame(3, ftell($handle));
18
+ $this->assertSame(3, fwrite($handle, 'bar'));
19
+ $this->assertSame(0, fseek($handle, 0));
20
+ $this->assertSame('foobar', fread($handle, 6));
21
+ $this->assertSame('', fread($handle, 1));
22
+ $this->assertTrue(feof($handle));
23
+
24
+ $stBlksize = defined('PHP_WINDOWS_VERSION_BUILD') ? -1 : 0;
25
+
26
+ // This fails on HHVM for some reason
27
+ if (!defined('HHVM_VERSION')) {
28
+ $this->assertEquals([
29
+ 'dev' => 0,
30
+ 'ino' => 0,
31
+ 'mode' => 33206,
32
+ 'nlink' => 0,
33
+ 'uid' => 0,
34
+ 'gid' => 0,
35
+ 'rdev' => 0,
36
+ 'size' => 6,
37
+ 'atime' => 0,
38
+ 'mtime' => 0,
39
+ 'ctime' => 0,
40
+ 'blksize' => $stBlksize,
41
+ 'blocks' => $stBlksize,
42
+ 0 => 0,
43
+ 1 => 0,
44
+ 2 => 33206,
45
+ 3 => 0,
46
+ 4 => 0,
47
+ 5 => 0,
48
+ 6 => 0,
49
+ 7 => 6,
50
+ 8 => 0,
51
+ 9 => 0,
52
+ 10 => 0,
53
+ 11 => $stBlksize,
54
+ 12 => $stBlksize,
55
+ ], fstat($handle));
56
+ }
57
+
58
+ $this->assertTrue(fclose($handle));
59
+ $this->assertSame('foobar', (string) $stream);
60
+ }
61
+
62
+ /**
63
+ * @expectedException \InvalidArgumentException
64
+ */
65
+ public function testValidatesStream()
66
+ {
67
+ $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
68
+ ->setMethods(['isReadable', 'isWritable'])
69
+ ->getMockForAbstractClass();
70
+ $stream->expects($this->once())
71
+ ->method('isReadable')
72
+ ->will($this->returnValue(false));
73
+ $stream->expects($this->once())
74
+ ->method('isWritable')
75
+ ->will($this->returnValue(false));
76
+ StreamWrapper::getResource($stream);
77
+ }
78
+
79
+ /**
80
+ * @expectedException \PHPUnit_Framework_Error_Warning
81
+ */
82
+ public function testReturnsFalseWhenStreamDoesNotExist()
83
+ {
84
+ fopen('guzzle://foo', 'r');
85
+ }
86
+
87
+ public function testCanOpenReadonlyStream()
88
+ {
89
+ $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
90
+ ->setMethods(['isReadable', 'isWritable'])
91
+ ->getMockForAbstractClass();
92
+ $stream->expects($this->once())
93
+ ->method('isReadable')
94
+ ->will($this->returnValue(false));
95
+ $stream->expects($this->once())
96
+ ->method('isWritable')
97
+ ->will($this->returnValue(true));
98
+ $r = StreamWrapper::getResource($stream);
99
+ $this->assertInternalType('resource', $r);
100
+ fclose($r);
101
+ }
102
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use ReflectionProperty;
5
+ use GuzzleHttp\Psr7\Stream;
6
+ use GuzzleHttp\Psr7\UploadedFile;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Psr7\UploadedFile
10
+ */
11
+ class UploadedFileTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ protected $cleanup;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->cleanup = [];
18
+ }
19
+
20
+ public function tearDown()
21
+ {
22
+ foreach ($this->cleanup as $file) {
23
+ if (is_scalar($file) && file_exists($file)) {
24
+ unlink($file);
25
+ }
26
+ }
27
+ }
28
+
29
+ public function invalidStreams()
30
+ {
31
+ return [
32
+ 'null' => [null],
33
+ 'true' => [true],
34
+ 'false' => [false],
35
+ 'int' => [1],
36
+ 'float' => [1.1],
37
+ 'array' => [['filename']],
38
+ 'object' => [(object) ['filename']],
39
+ ];
40
+ }
41
+
42
+ /**
43
+ * @dataProvider invalidStreams
44
+ */
45
+ public function testRaisesExceptionOnInvalidStreamOrFile($streamOrFile)
46
+ {
47
+ $this->setExpectedException('InvalidArgumentException');
48
+
49
+ new UploadedFile($streamOrFile, 0, UPLOAD_ERR_OK);
50
+ }
51
+
52
+ public function invalidSizes()
53
+ {
54
+ return [
55
+ 'null' => [null],
56
+ 'float' => [1.1],
57
+ 'array' => [[1]],
58
+ 'object' => [(object) [1]],
59
+ ];
60
+ }
61
+
62
+ /**
63
+ * @dataProvider invalidSizes
64
+ */
65
+ public function testRaisesExceptionOnInvalidSize($size)
66
+ {
67
+ $this->setExpectedException('InvalidArgumentException', 'size');
68
+
69
+ new UploadedFile(fopen('php://temp', 'wb+'), $size, UPLOAD_ERR_OK);
70
+ }
71
+
72
+ public function invalidErrorStatuses()
73
+ {
74
+ return [
75
+ 'null' => [null],
76
+ 'true' => [true],
77
+ 'false' => [false],
78
+ 'float' => [1.1],
79
+ 'string' => ['1'],
80
+ 'array' => [[1]],
81
+ 'object' => [(object) [1]],
82
+ 'negative' => [-1],
83
+ 'too-big' => [9],
84
+ ];
85
+ }
86
+
87
+ /**
88
+ * @dataProvider invalidErrorStatuses
89
+ */
90
+ public function testRaisesExceptionOnInvalidErrorStatus($status)
91
+ {
92
+ $this->setExpectedException('InvalidArgumentException', 'status');
93
+
94
+ new UploadedFile(fopen('php://temp', 'wb+'), 0, $status);
95
+ }
96
+
97
+ public function invalidFilenamesAndMediaTypes()
98
+ {
99
+ return [
100
+ 'true' => [true],
101
+ 'false' => [false],
102
+ 'int' => [1],
103
+ 'float' => [1.1],
104
+ 'array' => [['string']],
105
+ 'object' => [(object) ['string']],
106
+ ];
107
+ }
108
+
109
+ /**
110
+ * @dataProvider invalidFilenamesAndMediaTypes
111
+ */
112
+ public function testRaisesExceptionOnInvalidClientFilename($filename)
113
+ {
114
+ $this->setExpectedException('InvalidArgumentException', 'filename');
115
+
116
+ new UploadedFile(fopen('php://temp', 'wb+'), 0, UPLOAD_ERR_OK, $filename);
117
+ }
118
+
119
+ /**
120
+ * @dataProvider invalidFilenamesAndMediaTypes
121
+ */
122
+ public function testRaisesExceptionOnInvalidClientMediaType($mediaType)
123
+ {
124
+ $this->setExpectedException('InvalidArgumentException', 'media type');
125
+
126
+ new UploadedFile(fopen('php://temp', 'wb+'), 0, UPLOAD_ERR_OK, 'foobar.baz', $mediaType);
127
+ }
128
+
129
+ public function testGetStreamReturnsOriginalStreamObject()
130
+ {
131
+ $stream = new Stream(fopen('php://temp', 'r'));
132
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
133
+
134
+ $this->assertSame($stream, $upload->getStream());
135
+ }
136
+
137
+ public function testGetStreamReturnsWrappedPhpStream()
138
+ {
139
+ $stream = fopen('php://temp', 'wb+');
140
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
141
+ $uploadStream = $upload->getStream()->detach();
142
+
143
+ $this->assertSame($stream, $uploadStream);
144
+ }
145
+
146
+ public function testGetStreamReturnsStreamForFile()
147
+ {
148
+ $this->cleanup[] = $stream = tempnam(sys_get_temp_dir(), 'stream_file');
149
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
150
+ $uploadStream = $upload->getStream();
151
+ $r = new ReflectionProperty($uploadStream, 'filename');
152
+ $r->setAccessible(true);
153
+
154
+ $this->assertSame($stream, $r->getValue($uploadStream));
155
+ }
156
+
157
+ public function testSuccessful()
158
+ {
159
+ $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!');
160
+ $upload = new UploadedFile($stream, $stream->getSize(), UPLOAD_ERR_OK, 'filename.txt', 'text/plain');
161
+
162
+ $this->assertEquals($stream->getSize(), $upload->getSize());
163
+ $this->assertEquals('filename.txt', $upload->getClientFilename());
164
+ $this->assertEquals('text/plain', $upload->getClientMediaType());
165
+
166
+ $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'successful');
167
+ $upload->moveTo($to);
168
+ $this->assertFileExists($to);
169
+ $this->assertEquals($stream->__toString(), file_get_contents($to));
170
+ }
171
+
172
+ public function invalidMovePaths()
173
+ {
174
+ return [
175
+ 'null' => [null],
176
+ 'true' => [true],
177
+ 'false' => [false],
178
+ 'int' => [1],
179
+ 'float' => [1.1],
180
+ 'empty' => [''],
181
+ 'array' => [['filename']],
182
+ 'object' => [(object) ['filename']],
183
+ ];
184
+ }
185
+
186
+ /**
187
+ * @dataProvider invalidMovePaths
188
+ */
189
+ public function testMoveRaisesExceptionForInvalidPath($path)
190
+ {
191
+ $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!');
192
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
193
+
194
+ $this->cleanup[] = $path;
195
+
196
+ $this->setExpectedException('InvalidArgumentException', 'path');
197
+ $upload->moveTo($path);
198
+ }
199
+
200
+ public function testMoveCannotBeCalledMoreThanOnce()
201
+ {
202
+ $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!');
203
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
204
+
205
+ $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'diac');
206
+ $upload->moveTo($to);
207
+ $this->assertTrue(file_exists($to));
208
+
209
+ $this->setExpectedException('RuntimeException', 'moved');
210
+ $upload->moveTo($to);
211
+ }
212
+
213
+ public function testCannotRetrieveStreamAfterMove()
214
+ {
215
+ $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!');
216
+ $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
217
+
218
+ $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'diac');
219
+ $upload->moveTo($to);
220
+ $this->assertFileExists($to);
221
+
222
+ $this->setExpectedException('RuntimeException', 'moved');
223
+ $upload->getStream();
224
+ }
225
+
226
+ public function nonOkErrorStatus()
227
+ {
228
+ return [
229
+ 'UPLOAD_ERR_INI_SIZE' => [ UPLOAD_ERR_INI_SIZE ],
230
+ 'UPLOAD_ERR_FORM_SIZE' => [ UPLOAD_ERR_FORM_SIZE ],
231
+ 'UPLOAD_ERR_PARTIAL' => [ UPLOAD_ERR_PARTIAL ],
232
+ 'UPLOAD_ERR_NO_FILE' => [ UPLOAD_ERR_NO_FILE ],
233
+ 'UPLOAD_ERR_NO_TMP_DIR' => [ UPLOAD_ERR_NO_TMP_DIR ],
234
+ 'UPLOAD_ERR_CANT_WRITE' => [ UPLOAD_ERR_CANT_WRITE ],
235
+ 'UPLOAD_ERR_EXTENSION' => [ UPLOAD_ERR_EXTENSION ],
236
+ ];
237
+ }
238
+
239
+ /**
240
+ * @dataProvider nonOkErrorStatus
241
+ */
242
+ public function testConstructorDoesNotRaiseExceptionForInvalidStreamWhenErrorStatusPresent($status)
243
+ {
244
+ $uploadedFile = new UploadedFile('not ok', 0, $status);
245
+ $this->assertSame($status, $uploadedFile->getError());
246
+ }
247
+
248
+ /**
249
+ * @dataProvider nonOkErrorStatus
250
+ */
251
+ public function testMoveToRaisesExceptionWhenErrorStatusPresent($status)
252
+ {
253
+ $uploadedFile = new UploadedFile('not ok', 0, $status);
254
+ $this->setExpectedException('RuntimeException', 'upload error');
255
+ $uploadedFile->moveTo(__DIR__ . '/' . uniqid());
256
+ }
257
+
258
+ /**
259
+ * @dataProvider nonOkErrorStatus
260
+ */
261
+ public function testGetStreamRaisesExceptionWhenErrorStatusPresent($status)
262
+ {
263
+ $uploadedFile = new UploadedFile('not ok', 0, $status);
264
+ $this->setExpectedException('RuntimeException', 'upload error');
265
+ $stream = $uploadedFile->getStream();
266
+ }
267
+
268
+ public function testMoveToCreatesStreamIfOnlyAFilenameWasProvided()
269
+ {
270
+ $this->cleanup[] = $from = tempnam(sys_get_temp_dir(), 'copy_from');
271
+ $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'copy_to');
272
+
273
+ copy(__FILE__, $from);
274
+
275
+ $uploadedFile = new UploadedFile($from, 100, UPLOAD_ERR_OK, basename($from), 'text/plain');
276
+ $uploadedFile->moveTo($to);
277
+
278
+ $this->assertFileEquals(__FILE__, $to);
279
+ }
280
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/UriTest.php ADDED
@@ -0,0 +1,573 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ use GuzzleHttp\Psr7\Uri;
5
+
6
+ /**
7
+ * @covers GuzzleHttp\Psr7\Uri
8
+ */
9
+ class UriTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ const RFC3986_BASE = 'http://a/b/c/d;p?q';
12
+
13
+ public function testParsesProvidedUri()
14
+ {
15
+ $uri = new Uri('https://user:pass@example.com:8080/path/123?q=abc#test');
16
+
17
+ $this->assertSame('https', $uri->getScheme());
18
+ $this->assertSame('user:pass@example.com:8080', $uri->getAuthority());
19
+ $this->assertSame('user:pass', $uri->getUserInfo());
20
+ $this->assertSame('example.com', $uri->getHost());
21
+ $this->assertSame(8080, $uri->getPort());
22
+ $this->assertSame('/path/123', $uri->getPath());
23
+ $this->assertSame('q=abc', $uri->getQuery());
24
+ $this->assertSame('test', $uri->getFragment());
25
+ $this->assertSame('https://user:pass@example.com:8080/path/123?q=abc#test', (string) $uri);
26
+ }
27
+
28
+ public function testCanTransformAndRetrievePartsIndividually()
29
+ {
30
+ $uri = (new Uri())
31
+ ->withScheme('https')
32
+ ->withUserInfo('user', 'pass')
33
+ ->withHost('example.com')
34
+ ->withPort(8080)
35
+ ->withPath('/path/123')
36
+ ->withQuery('q=abc')
37
+ ->withFragment('test');
38
+
39
+ $this->assertSame('https', $uri->getScheme());
40
+ $this->assertSame('user:pass@example.com:8080', $uri->getAuthority());
41
+ $this->assertSame('user:pass', $uri->getUserInfo());
42
+ $this->assertSame('example.com', $uri->getHost());
43
+ $this->assertSame(8080, $uri->getPort());
44
+ $this->assertSame('/path/123', $uri->getPath());
45
+ $this->assertSame('q=abc', $uri->getQuery());
46
+ $this->assertSame('test', $uri->getFragment());
47
+ $this->assertSame('https://user:pass@example.com:8080/path/123?q=abc#test', (string) $uri);
48
+ }
49
+
50
+ /**
51
+ * @dataProvider getValidUris
52
+ */
53
+ public function testValidUrisStayValid($input)
54
+ {
55
+ $uri = new Uri($input);
56
+
57
+ $this->assertSame($input, (string) $uri);
58
+ }
59
+
60
+ /**
61
+ * @dataProvider getValidUris
62
+ */
63
+ public function testFromParts($input)
64
+ {
65
+ $uri = Uri::fromParts(parse_url($input));
66
+
67
+ $this->assertSame($input, (string) $uri);
68
+ }
69
+
70
+ public function getValidUris()
71
+ {
72
+ return [
73
+ ['urn:path-rootless'],
74
+ ['urn:path:with:colon'],
75
+ ['urn:/path-absolute'],
76
+ ['urn:/'],
77
+ // only scheme with empty path
78
+ ['urn:'],
79
+ // only path
80
+ ['/'],
81
+ ['relative/'],
82
+ ['0'],
83
+ // same document reference
84
+ [''],
85
+ // network path without scheme
86
+ ['//example.org'],
87
+ ['//example.org/'],
88
+ ['//example.org?q#h'],
89
+ // only query
90
+ ['?q'],
91
+ ['?q=abc&foo=bar'],
92
+ // only fragment
93
+ ['#fragment'],
94
+ // dot segments are not removed automatically
95
+ ['./foo/../bar'],
96
+ ];
97
+ }
98
+
99
+ /**
100
+ * @expectedException \InvalidArgumentException
101
+ * @expectedExceptionMessage Unable to parse URI
102
+ * @dataProvider getInvalidUris
103
+ */
104
+ public function testInvalidUrisThrowException($invalidUri)
105
+ {
106
+ new Uri($invalidUri);
107
+ }
108
+
109
+ public function getInvalidUris()
110
+ {
111
+ return [
112
+ // parse_url() requires the host component which makes sense for http(s)
113
+ // but not when the scheme is not known or different. So '//' or '///' is
114
+ // currently invalid as well but should not according to RFC 3986.
115
+ ['http://'],
116
+ ['urn://host:with:colon'], // host cannot contain ":"
117
+ ];
118
+ }
119
+
120
+ /**
121
+ * @expectedException \InvalidArgumentException
122
+ * @expectedExceptionMessage Invalid port: 100000. Must be between 1 and 65535
123
+ */
124
+ public function testPortMustBeValid()
125
+ {
126
+ (new Uri())->withPort(100000);
127
+ }
128
+
129
+ /**
130
+ * @expectedException \InvalidArgumentException
131
+ * @expectedExceptionMessage Invalid port: 0. Must be between 1 and 65535
132
+ */
133
+ public function testWithPortCannotBeZero()
134
+ {
135
+ (new Uri())->withPort(0);
136
+ }
137
+
138
+ /**
139
+ * @expectedException \InvalidArgumentException
140
+ * @expectedExceptionMessage Unable to parse URI
141
+ */
142
+ public function testParseUriPortCannotBeZero()
143
+ {
144
+ new Uri('//example.com:0');
145
+ }
146
+
147
+ /**
148
+ * @expectedException \InvalidArgumentException
149
+ */
150
+ public function testSchemeMustHaveCorrectType()
151
+ {
152
+ (new Uri())->withScheme([]);
153
+ }
154
+
155
+ /**
156
+ * @expectedException \InvalidArgumentException
157
+ */
158
+ public function testHostMustHaveCorrectType()
159
+ {
160
+ (new Uri())->withHost([]);
161
+ }
162
+
163
+ /**
164
+ * @expectedException \InvalidArgumentException
165
+ */
166
+ public function testPathMustHaveCorrectType()
167
+ {
168
+ (new Uri())->withPath([]);
169
+ }
170
+
171
+ /**
172
+ * @expectedException \InvalidArgumentException
173
+ */
174
+ public function testQueryMustHaveCorrectType()
175
+ {
176
+ (new Uri())->withQuery([]);
177
+ }
178
+
179
+ /**
180
+ * @expectedException \InvalidArgumentException
181
+ */
182
+ public function testFragmentMustHaveCorrectType()
183
+ {
184
+ (new Uri())->withFragment([]);
185
+ }
186
+
187
+ public function testCanParseFalseyUriParts()
188
+ {
189
+ $uri = new Uri('0://0:0@0/0?0#0');
190
+
191
+ $this->assertSame('0', $uri->getScheme());
192
+ $this->assertSame('0:0@0', $uri->getAuthority());
193
+ $this->assertSame('0:0', $uri->getUserInfo());
194
+ $this->assertSame('0', $uri->getHost());
195
+ $this->assertSame('/0', $uri->getPath());
196
+ $this->assertSame('0', $uri->getQuery());
197
+ $this->assertSame('0', $uri->getFragment());
198
+ $this->assertSame('0://0:0@0/0?0#0', (string) $uri);
199
+ }
200
+
201
+ public function testCanConstructFalseyUriParts()
202
+ {
203
+ $uri = (new Uri())
204
+ ->withScheme('0')
205
+ ->withUserInfo('0', '0')
206
+ ->withHost('0')
207
+ ->withPath('/0')
208
+ ->withQuery('0')
209
+ ->withFragment('0');
210
+
211
+ $this->assertSame('0', $uri->getScheme());
212
+ $this->assertSame('0:0@0', $uri->getAuthority());
213
+ $this->assertSame('0:0', $uri->getUserInfo());
214
+ $this->assertSame('0', $uri->getHost());
215
+ $this->assertSame('/0', $uri->getPath());
216
+ $this->assertSame('0', $uri->getQuery());
217
+ $this->assertSame('0', $uri->getFragment());
218
+ $this->assertSame('0://0:0@0/0?0#0', (string) $uri);
219
+ }
220
+
221
+ /**
222
+ * @dataProvider getResolveTestCases
223
+ */
224
+ public function testResolvesUris($base, $rel, $expected)
225
+ {
226
+ $uri = new Uri($base);
227
+ $actual = Uri::resolve($uri, $rel);
228
+ $this->assertSame($expected, (string) $actual);
229
+ }
230
+
231
+ public function getResolveTestCases()
232
+ {
233
+ return [
234
+ [self::RFC3986_BASE, 'g:h', 'g:h'],
235
+ [self::RFC3986_BASE, 'g', 'http://a/b/c/g'],
236
+ [self::RFC3986_BASE, './g', 'http://a/b/c/g'],
237
+ [self::RFC3986_BASE, 'g/', 'http://a/b/c/g/'],
238
+ [self::RFC3986_BASE, '/g', 'http://a/g'],
239
+ [self::RFC3986_BASE, '//g', 'http://g'],
240
+ [self::RFC3986_BASE, '?y', 'http://a/b/c/d;p?y'],
241
+ [self::RFC3986_BASE, 'g?y', 'http://a/b/c/g?y'],
242
+ [self::RFC3986_BASE, '#s', 'http://a/b/c/d;p?q#s'],
243
+ [self::RFC3986_BASE, 'g#s', 'http://a/b/c/g#s'],
244
+ [self::RFC3986_BASE, 'g?y#s', 'http://a/b/c/g?y#s'],
245
+ [self::RFC3986_BASE, ';x', 'http://a/b/c/;x'],
246
+ [self::RFC3986_BASE, 'g;x', 'http://a/b/c/g;x'],
247
+ [self::RFC3986_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s'],
248
+ [self::RFC3986_BASE, '', self::RFC3986_BASE],
249
+ [self::RFC3986_BASE, '.', 'http://a/b/c/'],
250
+ [self::RFC3986_BASE, './', 'http://a/b/c/'],
251
+ [self::RFC3986_BASE, '..', 'http://a/b/'],
252
+ [self::RFC3986_BASE, '../', 'http://a/b/'],
253
+ [self::RFC3986_BASE, '../g', 'http://a/b/g'],
254
+ [self::RFC3986_BASE, '../..', 'http://a/'],
255
+ [self::RFC3986_BASE, '../../', 'http://a/'],
256
+ [self::RFC3986_BASE, '../../g', 'http://a/g'],
257
+ [self::RFC3986_BASE, '../../../g', 'http://a/g'],
258
+ [self::RFC3986_BASE, '../../../../g', 'http://a/g'],
259
+ [self::RFC3986_BASE, '/./g', 'http://a/g'],
260
+ [self::RFC3986_BASE, '/../g', 'http://a/g'],
261
+ [self::RFC3986_BASE, 'g.', 'http://a/b/c/g.'],
262
+ [self::RFC3986_BASE, '.g', 'http://a/b/c/.g'],
263
+ [self::RFC3986_BASE, 'g..', 'http://a/b/c/g..'],
264
+ [self::RFC3986_BASE, '..g', 'http://a/b/c/..g'],
265
+ [self::RFC3986_BASE, './../g', 'http://a/b/g'],
266
+ [self::RFC3986_BASE, 'foo////g', 'http://a/b/c/foo////g'],
267
+ [self::RFC3986_BASE, './g/.', 'http://a/b/c/g/'],
268
+ [self::RFC3986_BASE, 'g/./h', 'http://a/b/c/g/h'],
269
+ [self::RFC3986_BASE, 'g/../h', 'http://a/b/c/h'],
270
+ [self::RFC3986_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y'],
271
+ [self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'],
272
+ // dot-segments in the query or fragment
273
+ [self::RFC3986_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x'],
274
+ [self::RFC3986_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x'],
275
+ [self::RFC3986_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x'],
276
+ [self::RFC3986_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x'],
277
+ [self::RFC3986_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x'],
278
+ [self::RFC3986_BASE, '?y#s', 'http://a/b/c/d;p?y#s'],
279
+ ['http://a/b/c/d;p?q#s', '?y', 'http://a/b/c/d;p?y'],
280
+ ['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'],
281
+ ['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
282
+ ['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'],
283
+ ['urn:no-slash', 'e', 'urn:e'],
284
+ // falsey relative parts
285
+ [self::RFC3986_BASE, '//0', 'http://0'],
286
+ [self::RFC3986_BASE, '0', 'http://a/b/c/0'],
287
+ [self::RFC3986_BASE, '?0', 'http://a/b/c/d;p?0'],
288
+ [self::RFC3986_BASE, '#0', 'http://a/b/c/d;p?q#0'],
289
+ ];
290
+ }
291
+
292
+ public function testAddAndRemoveQueryValues()
293
+ {
294
+ $uri = new Uri();
295
+ $uri = Uri::withQueryValue($uri, 'a', 'b');
296
+ $uri = Uri::withQueryValue($uri, 'c', 'd');
297
+ $uri = Uri::withQueryValue($uri, 'e', null);
298
+ $this->assertSame('a=b&c=d&e', $uri->getQuery());
299
+
300
+ $uri = Uri::withoutQueryValue($uri, 'c');
301
+ $this->assertSame('a=b&e', $uri->getQuery());
302
+ $uri = Uri::withoutQueryValue($uri, 'e');
303
+ $this->assertSame('a=b', $uri->getQuery());
304
+ $uri = Uri::withoutQueryValue($uri, 'a');
305
+ $this->assertSame('', $uri->getQuery());
306
+ }
307
+
308
+ public function testWithQueryValueReplacesSameKeys()
309
+ {
310
+ $uri = new Uri();
311
+ $uri = Uri::withQueryValue($uri, 'a', 'b');
312
+ $uri = Uri::withQueryValue($uri, 'c', 'd');
313
+ $uri = Uri::withQueryValue($uri, 'a', 'e');
314
+ $this->assertSame('c=d&a=e', $uri->getQuery());
315
+ }
316
+
317
+ public function testWithoutQueryValueRemovesAllSameKeys()
318
+ {
319
+ $uri = (new Uri())->withQuery('a=b&c=d&a=e');
320
+ $uri = Uri::withoutQueryValue($uri, 'a');
321
+ $this->assertSame('c=d', $uri->getQuery());
322
+ }
323
+
324
+ public function testRemoveNonExistingQueryValue()
325
+ {
326
+ $uri = new Uri();
327
+ $uri = Uri::withQueryValue($uri, 'a', 'b');
328
+ $uri = Uri::withoutQueryValue($uri, 'c');
329
+ $this->assertSame('a=b', $uri->getQuery());
330
+ }
331
+
332
+ public function testWithQueryValueHandlesEncoding()
333
+ {
334
+ $uri = new Uri();
335
+ $uri = Uri::withQueryValue($uri, 'E=mc^2', 'ein&stein');
336
+ $this->assertSame('E%3Dmc%5E2=ein%26stein', $uri->getQuery(), 'Decoded key/value get encoded');
337
+
338
+ $uri = new Uri();
339
+ $uri = Uri::withQueryValue($uri, 'E%3Dmc%5e2', 'ein%26stein');
340
+ $this->assertSame('E%3Dmc%5e2=ein%26stein', $uri->getQuery(), 'Encoded key/value do not get double-encoded');
341
+ }
342
+
343
+ public function testWithoutQueryValueHandlesEncoding()
344
+ {
345
+ // It also tests that the case of the percent-encoding does not matter,
346
+ // i.e. both lowercase "%3d" and uppercase "%5E" can be removed.
347
+ $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar');
348
+ $uri = Uri::withoutQueryValue($uri, 'E=mc^2');
349
+ $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in decoded form');
350
+
351
+ $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar');
352
+ $uri = Uri::withoutQueryValue($uri, 'E%3Dmc%5e2');
353
+ $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in encoded form');
354
+ }
355
+
356
+ public function testSchemeIsNormalizedToLowercase()
357
+ {
358
+ $uri = new Uri('HTTP://example.com');
359
+
360
+ $this->assertSame('http', $uri->getScheme());
361
+ $this->assertSame('http://example.com', (string) $uri);
362
+
363
+ $uri = (new Uri('//example.com'))->withScheme('HTTP');
364
+
365
+ $this->assertSame('http', $uri->getScheme());
366
+ $this->assertSame('http://example.com', (string) $uri);
367
+ }
368
+
369
+ public function testHostIsNormalizedToLowercase()
370
+ {
371
+ $uri = new Uri('//eXaMpLe.CoM');
372
+
373
+ $this->assertSame('example.com', $uri->getHost());
374
+ $this->assertSame('//example.com', (string) $uri);
375
+
376
+ $uri = (new Uri())->withHost('eXaMpLe.CoM');
377
+
378
+ $this->assertSame('example.com', $uri->getHost());
379
+ $this->assertSame('//example.com', (string) $uri);
380
+ }
381
+
382
+ public function testPortIsNullIfStandardPortForScheme()
383
+ {
384
+ // HTTPS standard port
385
+ $uri = new Uri('https://example.com:443');
386
+ $this->assertNull($uri->getPort());
387
+ $this->assertSame('example.com', $uri->getAuthority());
388
+
389
+ $uri = (new Uri('https://example.com'))->withPort(443);
390
+ $this->assertNull($uri->getPort());
391
+ $this->assertSame('example.com', $uri->getAuthority());
392
+
393
+ // HTTP standard port
394
+ $uri = new Uri('http://example.com:80');
395
+ $this->assertNull($uri->getPort());
396
+ $this->assertSame('example.com', $uri->getAuthority());
397
+
398
+ $uri = (new Uri('http://example.com'))->withPort(80);
399
+ $this->assertNull($uri->getPort());
400
+ $this->assertSame('example.com', $uri->getAuthority());
401
+ }
402
+
403
+ public function testPortIsReturnedIfSchemeUnknown()
404
+ {
405
+ $uri = (new Uri('//example.com'))->withPort(80);
406
+
407
+ $this->assertSame(80, $uri->getPort());
408
+ $this->assertSame('example.com:80', $uri->getAuthority());
409
+ }
410
+
411
+ public function testStandardPortIsNullIfSchemeChanges()
412
+ {
413
+ $uri = new Uri('http://example.com:443');
414
+ $this->assertSame('http', $uri->getScheme());
415
+ $this->assertSame(443, $uri->getPort());
416
+
417
+ $uri = $uri->withScheme('https');
418
+ $this->assertNull($uri->getPort());
419
+ }
420
+
421
+ public function testPortPassedAsStringIsCastedToInt()
422
+ {
423
+ $uri = (new Uri('//example.com'))->withPort('8080');
424
+
425
+ $this->assertSame(8080, $uri->getPort(), 'Port is returned as integer');
426
+ $this->assertSame('example.com:8080', $uri->getAuthority());
427
+ }
428
+
429
+ public function testPortCanBeRemoved()
430
+ {
431
+ $uri = (new Uri('http://example.com:8080'))->withPort(null);
432
+
433
+ $this->assertNull($uri->getPort());
434
+ $this->assertSame('http://example.com', (string) $uri);
435
+ }
436
+
437
+ public function testAuthorityWithUserInfoButWithoutHost()
438
+ {
439
+ $uri = (new Uri())->withUserInfo('user', 'pass');
440
+
441
+ $this->assertSame('user:pass', $uri->getUserInfo());
442
+ $this->assertSame('', $uri->getAuthority());
443
+ }
444
+
445
+ public function uriComponentsEncodingProvider()
446
+ {
447
+ $unreserved = 'a-zA-Z0-9.-_~!$&\'()*+,;=:@';
448
+
449
+ return [
450
+ // Percent encode spaces
451
+ ['/pa th?q=va lue#frag ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'],
452
+ // Percent encode multibyte
453
+ ['/€?€#€', '/%E2%82%AC', '%E2%82%AC', '%E2%82%AC', '/%E2%82%AC?%E2%82%AC#%E2%82%AC'],
454
+ // Don't encode something that's already encoded
455
+ ['/pa%20th?q=va%20lue#frag%20ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'],
456
+ // Percent encode invalid percent encodings
457
+ ['/pa%2-th?q=va%2-lue#frag%2-ment', '/pa%252-th', 'q=va%252-lue', 'frag%252-ment', '/pa%252-th?q=va%252-lue#frag%252-ment'],
458
+ // Don't encode path segments
459
+ ['/pa/th//two?q=va/lue#frag/ment', '/pa/th//two', 'q=va/lue', 'frag/ment', '/pa/th//two?q=va/lue#frag/ment'],
460
+ // Don't encode unreserved chars or sub-delimiters
461
+ ["/$unreserved?$unreserved#$unreserved", "/$unreserved", $unreserved, $unreserved, "/$unreserved?$unreserved#$unreserved"],
462
+ // Encoded unreserved chars are not decoded
463
+ ['/p%61th?q=v%61lue#fr%61gment', '/p%61th', 'q=v%61lue', 'fr%61gment', '/p%61th?q=v%61lue#fr%61gment'],
464
+ ];
465
+ }
466
+
467
+ /**
468
+ * @dataProvider uriComponentsEncodingProvider
469
+ */
470
+ public function testUriComponentsGetEncodedProperly($input, $path, $query, $fragment, $output)
471
+ {
472
+ $uri = new Uri($input);
473
+ $this->assertSame($path, $uri->getPath());
474
+ $this->assertSame($query, $uri->getQuery());
475
+ $this->assertSame($fragment, $uri->getFragment());
476
+ $this->assertSame($output, (string) $uri);
477
+ }
478
+
479
+ public function testWithPathEncodesProperly()
480
+ {
481
+ $uri = (new Uri())->withPath('/baz?#€/b%61r');
482
+ // Query and fragment delimiters and multibyte chars are encoded.
483
+ $this->assertSame('/baz%3F%23%E2%82%AC/b%61r', $uri->getPath());
484
+ $this->assertSame('/baz%3F%23%E2%82%AC/b%61r', (string) $uri);
485
+ }
486
+
487
+ public function testWithQueryEncodesProperly()
488
+ {
489
+ $uri = (new Uri())->withQuery('?=#&€=/&b%61r');
490
+ // A query starting with a "?" is valid and must not be magically removed. Otherwise it would be impossible to
491
+ // construct such an URI. Also the "?" and "/" does not need to be encoded in the query.
492
+ $this->assertSame('?=%23&%E2%82%AC=/&b%61r', $uri->getQuery());
493
+ $this->assertSame('??=%23&%E2%82%AC=/&b%61r', (string) $uri);
494
+ }
495
+
496
+ public function testWithFragmentEncodesProperly()
497
+ {
498
+ $uri = (new Uri())->withFragment('#€?/b%61r');
499
+ // A fragment starting with a "#" is valid and must not be magically removed. Otherwise it would be impossible to
500
+ // construct such an URI. Also the "?" and "/" does not need to be encoded in the fragment.
501
+ $this->assertSame('%23%E2%82%AC?/b%61r', $uri->getFragment());
502
+ $this->assertSame('#%23%E2%82%AC?/b%61r', (string) $uri);
503
+ }
504
+
505
+ public function testAllowsForRelativeUri()
506
+ {
507
+ $uri = (new Uri)->withPath('foo');
508
+ $this->assertSame('foo', $uri->getPath());
509
+ $this->assertSame('foo', (string) $uri);
510
+ }
511
+
512
+ public function testAddsSlashForRelativeUriStringWithHost()
513
+ {
514
+ // If the path is rootless and an authority is present, the path MUST
515
+ // be prefixed by "/".
516
+ $uri = (new Uri)->withPath('foo')->withHost('example.com');
517
+ $this->assertSame('foo', $uri->getPath());
518
+ // concatenating a relative path with a host doesn't work: "//example.comfoo" would be wrong
519
+ $this->assertSame('//example.com/foo', (string) $uri);
520
+ }
521
+
522
+ public function testRemoveExtraSlashesWihoutHost()
523
+ {
524
+ // If the path is starting with more than one "/" and no authority is
525
+ // present, the starting slashes MUST be reduced to one.
526
+ $uri = (new Uri)->withPath('//foo');
527
+ $this->assertSame('//foo', $uri->getPath());
528
+ // URI "//foo" would be interpreted as network reference and thus change the original path to the host
529
+ $this->assertSame('/foo', (string) $uri);
530
+ }
531
+
532
+ public function testDefaultReturnValuesOfGetters()
533
+ {
534
+ $uri = new Uri();
535
+
536
+ $this->assertSame('', $uri->getScheme());
537
+ $this->assertSame('', $uri->getAuthority());
538
+ $this->assertSame('', $uri->getUserInfo());
539
+ $this->assertSame('', $uri->getHost());
540
+ $this->assertNull($uri->getPort());
541
+ $this->assertSame('', $uri->getPath());
542
+ $this->assertSame('', $uri->getQuery());
543
+ $this->assertSame('', $uri->getFragment());
544
+ }
545
+
546
+ public function testImmutability()
547
+ {
548
+ $uri = new Uri();
549
+
550
+ $this->assertNotSame($uri, $uri->withScheme('https'));
551
+ $this->assertNotSame($uri, $uri->withUserInfo('user', 'pass'));
552
+ $this->assertNotSame($uri, $uri->withHost('example.com'));
553
+ $this->assertNotSame($uri, $uri->withPort(8080));
554
+ $this->assertNotSame($uri, $uri->withPath('/path/123'));
555
+ $this->assertNotSame($uri, $uri->withQuery('q=abc'));
556
+ $this->assertNotSame($uri, $uri->withFragment('test'));
557
+ }
558
+
559
+ public function testExtendingClassesInstantiates()
560
+ {
561
+ // The non-standard port triggers a cascade of private methods which
562
+ // should not use late static binding to access private static members.
563
+ // If they do, this will fatal.
564
+ $this->assertInstanceOf(
565
+ '\GuzzleHttp\Tests\Psr7\ExtendingClassTest',
566
+ new ExtendingClassTest('http://h:9/')
567
+ );
568
+ }
569
+ }
570
+
571
+ class ExtendingClassTest extends \GuzzleHttp\Psr7\Uri
572
+ {
573
+ }
app/code/community/VeInteractive/VePlatform/vendor/guzzlehttp/psr7/tests/bootstrap.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Psr7;
3
+
4
+ require __DIR__ . '/../vendor/autoload.php';
5
+
6
+ class HasToString
7
+ {
8
+ public function __toString() {
9
+ return 'foo';
10
+ }
11
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/Application.Insights.phpproj ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
+ <Name>Application.Insights</Name>
6
+ <ProjectGuid>6c54eac1-21b0-4dbe-a7c8-59e4a4f81316</ProjectGuid>
7
+ <OutputType>Console</OutputType>
8
+ <RootNamespace>Application.Insights</RootNamespace>
9
+ <ProjectTypeGuids>{A0786B88-2ADB-4C21-ABE8-AA2D79766269}</ProjectTypeGuids>
10
+ <StartupFile>
11
+ </StartupFile>
12
+ <AssemblyName>Application.Insights</AssemblyName>
13
+ </PropertyGroup>
14
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
15
+ <IncludeDebugInformation>true</IncludeDebugInformation>
16
+ </PropertyGroup>
17
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
18
+ <IncludeDebugInformation>false</IncludeDebugInformation>
19
+ </PropertyGroup>
20
+ <ItemGroup>
21
+ <Compile Include="ApplicationInsights\Channel\Contracts\Application.php" />
22
+ <Compile Include="ApplicationInsights\Channel\Contracts\Data.php" />
23
+ <Compile Include="ApplicationInsights\Channel\Contracts\Data_Point.php" />
24
+ <Compile Include="ApplicationInsights\Channel\Contracts\Data_Point_Type.php" />
25
+ <Compile Include="ApplicationInsights\Channel\Contracts\Device.php" />
26
+ <Compile Include="ApplicationInsights\Channel\Contracts\Envelope.php" />
27
+ <Compile Include="ApplicationInsights\Channel\Contracts\Event_Data.php" />
28
+ <Compile Include="ApplicationInsights\Channel\Contracts\Exception_Data.php" />
29
+ <Compile Include="ApplicationInsights\Channel\Contracts\Exception_Details.php" />
30
+ <Compile Include="ApplicationInsights\Channel\Contracts\Internal.php" />
31
+ <Compile Include="ApplicationInsights\Channel\Contracts\Location.php" />
32
+ <Compile Include="ApplicationInsights\Channel\Contracts\Message_Data.php" />
33
+ <Compile Include="ApplicationInsights\Channel\Contracts\Metric_Data.php" />
34
+ <Compile Include="ApplicationInsights\Channel\Contracts\Operation.php" />
35
+ <Compile Include="ApplicationInsights\Channel\Contracts\Page_View_Data.php" />
36
+ <Compile Include="ApplicationInsights\Channel\Contracts\Request_Data.php" />
37
+ <Compile Include="ApplicationInsights\Channel\Contracts\Session.php" />
38
+ <Compile Include="ApplicationInsights\Channel\Contracts\Stack_Frame.php" />
39
+ <Compile Include="ApplicationInsights\Channel\Contracts\User.php" />
40
+ <Compile Include="ApplicationInsights\Channel\Contracts\Utils.php" />
41
+ <Compile Include="ApplicationInsights\Current_User.php" />
42
+ <Compile Include="ApplicationInsights\Current_Session.php" />
43
+ <Compile Include="ApplicationInsights\Telemetry_Context.php" />
44
+ <Compile Include="ApplicationInsights\Channel\Telemetry_Channel.php" />
45
+ <Compile Include="ApplicationInsights\Telemetry_Client.php" />
46
+ <Compile Include="ApplicationInsights\Tests\Bootstrap.php" />
47
+ <Compile Include="ApplicationInsights\Tests\Channel\Contracts\Utils_Test.php" />
48
+ <Compile Include="ApplicationInsights\Tests\Current_User_Test.php" />
49
+ <Compile Include="ApplicationInsights\Tests\Current_Session_Test.php" />
50
+ <Compile Include="ApplicationInsights\Tests\Utils.php" />
51
+ <Compile Include="ApplicationInsights\Tests\Telemetry_Context_Test.php" />
52
+ <Compile Include="ApplicationInsights\Tests\Telemetry_Client_Test.php" />
53
+ <Compile Include="ApplicationInsights\Tests\Channel\Telemetry_Channel_Test.php" />
54
+ </ItemGroup>
55
+ <ItemGroup>
56
+ <Folder Include="ApplicationInsights\" />
57
+ <Folder Include="ApplicationInsights\Channel\" />
58
+ <Folder Include="ApplicationInsights\Channel\Contracts\" />
59
+ <Folder Include="ApplicationInsights\Tests\" />
60
+ <Folder Include="ApplicationInsights\Tests\Channel\" />
61
+ <Folder Include="ApplicationInsights\Tests\Channel\Contracts\" />
62
+ </ItemGroup>
63
+ <ItemGroup>
64
+ <Content Include=".gitattributes" />
65
+ <Content Include=".gitignore" />
66
+ <Content Include="composer.json" />
67
+ <Content Include="LICENSE.txt" />
68
+ <Content Include="phpdoc.xml" />
69
+ <Content Include="phpunit.xml" />
70
+ <Content Include="README.md" />
71
+ </ItemGroup>
72
+ </Project>
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/Application.Insights.sln ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio 2013
4
+ VisualStudioVersion = 12.0.30723.0
5
+ MinimumVisualStudioVersion = 10.0.40219.1
6
+ Project("{A0786B88-2ADB-4C21-ABE8-AA2D79766269}") = "Application.Insights", "Application.Insights.phpproj", "{6C54EAC1-21B0-4DBE-A7C8-59E4A4F81316}"
7
+ EndProject
8
+ Global
9
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|Any CPU = Debug|Any CPU
11
+ Release|Any CPU = Release|Any CPU
12
+ EndGlobalSection
13
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+ {6C54EAC1-21B0-4DBE-A7C8-59E4A4F81316}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+ {6C54EAC1-21B0-4DBE-A7C8-59E4A4F81316}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+ {6C54EAC1-21B0-4DBE-A7C8-59E4A4F81316}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+ {6C54EAC1-21B0-4DBE-A7C8-59E4A4F81316}.Release|Any CPU.Build.0 = Release|Any CPU
18
+ EndGlobalSection
19
+ GlobalSection(SolutionProperties) = preSolution
20
+ HideSolutionNode = FALSE
21
+ EndGlobalSection
22
+ EndGlobal
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Application.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Application.
6
+ */
7
+ class Application
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Application.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the ver field.
24
+ */
25
+ public function getVer()
26
+ {
27
+ if (array_key_exists('ai.application.ver', $this->_data)) { return $this->_data['ai.application.ver']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the ver field.
33
+ */
34
+ public function setVer($ver)
35
+ {
36
+ $this->_data['ai.application.ver'] = $ver;
37
+ }
38
+
39
+ /**
40
+ * Overrides JSON serialization for this class.
41
+ */
42
+ public function jsonSerialize()
43
+ {
44
+ return Utils::removeEmptyValues($this->_data);
45
+ }
46
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Data.
6
+ */
7
+ class Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Data.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data['baseData'] = NULL;
20
+ }
21
+
22
+ /**
23
+ * Gets the baseType field.
24
+ */
25
+ public function getBaseType()
26
+ {
27
+ if (array_key_exists('baseType', $this->_data)) { return $this->_data['baseType']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the baseType field.
33
+ */
34
+ public function setBaseType($baseType)
35
+ {
36
+ $this->_data['baseType'] = $baseType;
37
+ }
38
+
39
+ /**
40
+ * Gets the baseData field.
41
+ */
42
+ public function getBaseData()
43
+ {
44
+ if (array_key_exists('baseData', $this->_data)) { return $this->_data['baseData']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the baseData field.
50
+ */
51
+ public function setBaseData($baseData)
52
+ {
53
+ $this->_data['baseData'] = $baseData;
54
+ }
55
+
56
+ /**
57
+ * Overrides JSON serialization for this class.
58
+ */
59
+ public function jsonSerialize()
60
+ {
61
+ return Utils::removeEmptyValues($this->_data);
62
+ }
63
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data_Point.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Data_Point.
6
+ */
7
+ class Data_Point
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new DataPoint.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data['name'] = NULL;
20
+ $this->_data['kind'] = Data_Point_Type::Measurement;
21
+ $this->_data['value'] = NULL;
22
+ }
23
+
24
+ /**
25
+ * Gets the name field.
26
+ */
27
+ public function getName()
28
+ {
29
+ if (array_key_exists('name', $this->_data)) { return $this->_data['name']; }
30
+ return NULL;
31
+ }
32
+
33
+ /**
34
+ * Sets the name field.
35
+ */
36
+ public function setName($name)
37
+ {
38
+ $this->_data['name'] = $name;
39
+ }
40
+
41
+ /**
42
+ * Gets the kind field.
43
+ */
44
+ public function getKind()
45
+ {
46
+ if (array_key_exists('kind', $this->_data)) { return $this->_data['kind']; }
47
+ return NULL;
48
+ }
49
+
50
+ /**
51
+ * Sets the kind field.
52
+ */
53
+ public function setKind($kind)
54
+ {
55
+ $this->_data['kind'] = $kind;
56
+ }
57
+
58
+ /**
59
+ * Gets the value field.
60
+ */
61
+ public function getValue()
62
+ {
63
+ if (array_key_exists('value', $this->_data)) { return $this->_data['value']; }
64
+ return NULL;
65
+ }
66
+
67
+ /**
68
+ * Sets the value field.
69
+ */
70
+ public function setValue($value)
71
+ {
72
+ $this->_data['value'] = $value;
73
+ }
74
+
75
+ /**
76
+ * Gets the count field.
77
+ */
78
+ public function getCount()
79
+ {
80
+ if (array_key_exists('count', $this->_data)) { return $this->_data['count']; }
81
+ return NULL;
82
+ }
83
+
84
+ /**
85
+ * Sets the count field.
86
+ */
87
+ public function setCount($count)
88
+ {
89
+ $this->_data['count'] = $count;
90
+ }
91
+
92
+ /**
93
+ * Gets the min field.
94
+ */
95
+ public function getMin()
96
+ {
97
+ if (array_key_exists('min', $this->_data)) { return $this->_data['min']; }
98
+ return NULL;
99
+ }
100
+
101
+ /**
102
+ * Sets the min field.
103
+ */
104
+ public function setMin($min)
105
+ {
106
+ $this->_data['min'] = $min;
107
+ }
108
+
109
+ /**
110
+ * Gets the max field.
111
+ */
112
+ public function getMax()
113
+ {
114
+ if (array_key_exists('max', $this->_data)) { return $this->_data['max']; }
115
+ return NULL;
116
+ }
117
+
118
+ /**
119
+ * Sets the max field.
120
+ */
121
+ public function setMax($max)
122
+ {
123
+ $this->_data['max'] = $max;
124
+ }
125
+
126
+ /**
127
+ * Gets the stdDev field.
128
+ */
129
+ public function getStdDev()
130
+ {
131
+ if (array_key_exists('stdDev', $this->_data)) { return $this->_data['stdDev']; }
132
+ return NULL;
133
+ }
134
+
135
+ /**
136
+ * Sets the stdDev field.
137
+ */
138
+ public function setStdDev($stdDev)
139
+ {
140
+ $this->_data['stdDev'] = $stdDev;
141
+ }
142
+
143
+ /**
144
+ * Overrides JSON serialization for this class.
145
+ */
146
+ public function jsonSerialize()
147
+ {
148
+ return Utils::removeEmptyValues($this->_data);
149
+ }
150
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Data_Point_Type.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+ /**
4
+ * Enum Data_Point_Type.
5
+ */
6
+ abstract class Data_Point_Type
7
+ {
8
+ const Measurement = 0;
9
+ const Aggregation = 1;
10
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Device.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Device.
6
+ */
7
+ class Device
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Device.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the id field.
24
+ */
25
+ public function getId()
26
+ {
27
+ if (array_key_exists('ai.device.id', $this->_data)) { return $this->_data['ai.device.id']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the id field.
33
+ */
34
+ public function setId($id)
35
+ {
36
+ $this->_data['ai.device.id'] = $id;
37
+ }
38
+
39
+ /**
40
+ * Gets the ip field.
41
+ */
42
+ public function getIp()
43
+ {
44
+ if (array_key_exists('ai.device.ip', $this->_data)) { return $this->_data['ai.device.ip']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the ip field.
50
+ */
51
+ public function setIp($ip)
52
+ {
53
+ $this->_data['ai.device.ip'] = $ip;
54
+ }
55
+
56
+ /**
57
+ * Gets the language field.
58
+ */
59
+ public function getLanguage()
60
+ {
61
+ if (array_key_exists('ai.device.language', $this->_data)) { return $this->_data['ai.device.language']; }
62
+ return NULL;
63
+ }
64
+
65
+ /**
66
+ * Sets the language field.
67
+ */
68
+ public function setLanguage($language)
69
+ {
70
+ $this->_data['ai.device.language'] = $language;
71
+ }
72
+
73
+ /**
74
+ * Gets the locale field.
75
+ */
76
+ public function getLocale()
77
+ {
78
+ if (array_key_exists('ai.device.locale', $this->_data)) { return $this->_data['ai.device.locale']; }
79
+ return NULL;
80
+ }
81
+
82
+ /**
83
+ * Sets the locale field.
84
+ */
85
+ public function setLocale($locale)
86
+ {
87
+ $this->_data['ai.device.locale'] = $locale;
88
+ }
89
+
90
+ /**
91
+ * Gets the model field.
92
+ */
93
+ public function getModel()
94
+ {
95
+ if (array_key_exists('ai.device.model', $this->_data)) { return $this->_data['ai.device.model']; }
96
+ return NULL;
97
+ }
98
+
99
+ /**
100
+ * Sets the model field.
101
+ */
102
+ public function setModel($model)
103
+ {
104
+ $this->_data['ai.device.model'] = $model;
105
+ }
106
+
107
+ /**
108
+ * Gets the network field.
109
+ */
110
+ public function getNetwork()
111
+ {
112
+ if (array_key_exists('ai.device.network', $this->_data)) { return $this->_data['ai.device.network']; }
113
+ return NULL;
114
+ }
115
+
116
+ /**
117
+ * Sets the network field.
118
+ */
119
+ public function setNetwork($network)
120
+ {
121
+ $this->_data['ai.device.network'] = $network;
122
+ }
123
+
124
+ /**
125
+ * Gets the oemName field.
126
+ */
127
+ public function getOemName()
128
+ {
129
+ if (array_key_exists('ai.device.oemName', $this->_data)) { return $this->_data['ai.device.oemName']; }
130
+ return NULL;
131
+ }
132
+
133
+ /**
134
+ * Sets the oemName field.
135
+ */
136
+ public function setOemName($oemName)
137
+ {
138
+ $this->_data['ai.device.oemName'] = $oemName;
139
+ }
140
+
141
+ /**
142
+ * Gets the os field.
143
+ */
144
+ public function getOs()
145
+ {
146
+ if (array_key_exists('ai.device.os', $this->_data)) { return $this->_data['ai.device.os']; }
147
+ return NULL;
148
+ }
149
+
150
+ /**
151
+ * Sets the os field.
152
+ */
153
+ public function setOs($os)
154
+ {
155
+ $this->_data['ai.device.os'] = $os;
156
+ }
157
+
158
+ /**
159
+ * Gets the osVersion field.
160
+ */
161
+ public function getOsVersion()
162
+ {
163
+ if (array_key_exists('ai.device.osVersion', $this->_data)) { return $this->_data['ai.device.osVersion']; }
164
+ return NULL;
165
+ }
166
+
167
+ /**
168
+ * Sets the osVersion field.
169
+ */
170
+ public function setOsVersion($osVersion)
171
+ {
172
+ $this->_data['ai.device.osVersion'] = $osVersion;
173
+ }
174
+
175
+ /**
176
+ * Gets the roleInstance field.
177
+ */
178
+ public function getRoleInstance()
179
+ {
180
+ if (array_key_exists('ai.device.roleInstance', $this->_data)) { return $this->_data['ai.device.roleInstance']; }
181
+ return NULL;
182
+ }
183
+
184
+ /**
185
+ * Sets the roleInstance field.
186
+ */
187
+ public function setRoleInstance($roleInstance)
188
+ {
189
+ $this->_data['ai.device.roleInstance'] = $roleInstance;
190
+ }
191
+
192
+ /**
193
+ * Gets the roleName field.
194
+ */
195
+ public function getRoleName()
196
+ {
197
+ if (array_key_exists('ai.device.roleName', $this->_data)) { return $this->_data['ai.device.roleName']; }
198
+ return NULL;
199
+ }
200
+
201
+ /**
202
+ * Sets the roleName field.
203
+ */
204
+ public function setRoleName($roleName)
205
+ {
206
+ $this->_data['ai.device.roleName'] = $roleName;
207
+ }
208
+
209
+ /**
210
+ * Gets the screenResolution field.
211
+ */
212
+ public function getScreenResolution()
213
+ {
214
+ if (array_key_exists('ai.device.screenResolution', $this->_data)) { return $this->_data['ai.device.screenResolution']; }
215
+ return NULL;
216
+ }
217
+
218
+ /**
219
+ * Sets the screenResolution field.
220
+ */
221
+ public function setScreenResolution($screenResolution)
222
+ {
223
+ $this->_data['ai.device.screenResolution'] = $screenResolution;
224
+ }
225
+
226
+ /**
227
+ * Gets the type field.
228
+ */
229
+ public function getType()
230
+ {
231
+ if (array_key_exists('ai.device.type', $this->_data)) { return $this->_data['ai.device.type']; }
232
+ return NULL;
233
+ }
234
+
235
+ /**
236
+ * Sets the type field.
237
+ */
238
+ public function setType($type)
239
+ {
240
+ $this->_data['ai.device.type'] = $type;
241
+ }
242
+
243
+ /**
244
+ * Gets the vmName field.
245
+ */
246
+ public function getVmName()
247
+ {
248
+ if (array_key_exists('ai.device.vmName', $this->_data)) { return $this->_data['ai.device.vmName']; }
249
+ return NULL;
250
+ }
251
+
252
+ /**
253
+ * Sets the vmName field.
254
+ */
255
+ public function setVmName($vmName)
256
+ {
257
+ $this->_data['ai.device.vmName'] = $vmName;
258
+ }
259
+
260
+ /**
261
+ * Overrides JSON serialization for this class.
262
+ */
263
+ public function jsonSerialize()
264
+ {
265
+ return Utils::removeEmptyValues($this->_data);
266
+ }
267
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Envelope.php ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Envelope.
6
+ */
7
+ class Envelope
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Envelope.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data['ver'] = 1;
20
+ $this->_data['name'] = NULL;
21
+ $this->_data['time'] = NULL;
22
+ $this->_data['sampleRate'] = 100.0;
23
+ }
24
+
25
+ /**
26
+ * Gets the ver field.
27
+ */
28
+ public function getVer()
29
+ {
30
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
31
+ return NULL;
32
+ }
33
+
34
+ /**
35
+ * Sets the ver field.
36
+ */
37
+ public function setVer($ver)
38
+ {
39
+ $this->_data['ver'] = $ver;
40
+ }
41
+
42
+ /**
43
+ * Gets the name field.
44
+ */
45
+ public function getName()
46
+ {
47
+ if (array_key_exists('name', $this->_data)) { return $this->_data['name']; }
48
+ return NULL;
49
+ }
50
+
51
+ /**
52
+ * Sets the name field.
53
+ */
54
+ public function setName($name)
55
+ {
56
+ $this->_data['name'] = $name;
57
+ }
58
+
59
+ /**
60
+ * Gets the time field.
61
+ */
62
+ public function getTime()
63
+ {
64
+ if (array_key_exists('time', $this->_data)) { return $this->_data['time']; }
65
+ return NULL;
66
+ }
67
+
68
+ /**
69
+ * Sets the time field.
70
+ */
71
+ public function setTime($time)
72
+ {
73
+ $this->_data['time'] = $time;
74
+ }
75
+
76
+ /**
77
+ * Gets the sampleRate field.
78
+ */
79
+ public function getSampleRate()
80
+ {
81
+ if (array_key_exists('sampleRate', $this->_data)) { return $this->_data['sampleRate']; }
82
+ return NULL;
83
+ }
84
+
85
+ /**
86
+ * Sets the sampleRate field.
87
+ */
88
+ public function setSampleRate($sampleRate)
89
+ {
90
+ $this->_data['sampleRate'] = $sampleRate;
91
+ }
92
+
93
+ /**
94
+ * Gets the seq field.
95
+ */
96
+ public function getSeq()
97
+ {
98
+ if (array_key_exists('seq', $this->_data)) { return $this->_data['seq']; }
99
+ return NULL;
100
+ }
101
+
102
+ /**
103
+ * Sets the seq field.
104
+ */
105
+ public function setSeq($seq)
106
+ {
107
+ $this->_data['seq'] = $seq;
108
+ }
109
+
110
+ /**
111
+ * Gets the iKey field.
112
+ */
113
+ public function getInstrumentationKey()
114
+ {
115
+ if (array_key_exists('iKey', $this->_data)) { return $this->_data['iKey']; }
116
+ return NULL;
117
+ }
118
+
119
+ /**
120
+ * Sets the iKey field.
121
+ */
122
+ public function setInstrumentationKey($iKey)
123
+ {
124
+ $this->_data['iKey'] = $iKey;
125
+ }
126
+
127
+ /**
128
+ * Gets the flags field.
129
+ */
130
+ public function getFlags()
131
+ {
132
+ if (array_key_exists('flags', $this->_data)) { return $this->_data['flags']; }
133
+ return NULL;
134
+ }
135
+
136
+ /**
137
+ * Sets the flags field.
138
+ */
139
+ public function setFlags($flags)
140
+ {
141
+ $this->_data['flags'] = $flags;
142
+ }
143
+
144
+ /**
145
+ * Gets the deviceId field.
146
+ */
147
+ public function getDeviceId()
148
+ {
149
+ if (array_key_exists('deviceId', $this->_data)) { return $this->_data['deviceId']; }
150
+ return NULL;
151
+ }
152
+
153
+ /**
154
+ * Sets the deviceId field.
155
+ */
156
+ public function setDeviceId($deviceId)
157
+ {
158
+ $this->_data['deviceId'] = $deviceId;
159
+ }
160
+
161
+ /**
162
+ * Gets the os field.
163
+ */
164
+ public function getOs()
165
+ {
166
+ if (array_key_exists('os', $this->_data)) { return $this->_data['os']; }
167
+ return NULL;
168
+ }
169
+
170
+ /**
171
+ * Sets the os field.
172
+ */
173
+ public function setOs($os)
174
+ {
175
+ $this->_data['os'] = $os;
176
+ }
177
+
178
+ /**
179
+ * Gets the osVer field.
180
+ */
181
+ public function getOsVer()
182
+ {
183
+ if (array_key_exists('osVer', $this->_data)) { return $this->_data['osVer']; }
184
+ return NULL;
185
+ }
186
+
187
+ /**
188
+ * Sets the osVer field.
189
+ */
190
+ public function setOsVer($osVer)
191
+ {
192
+ $this->_data['osVer'] = $osVer;
193
+ }
194
+
195
+ /**
196
+ * Gets the appId field.
197
+ */
198
+ public function getAppId()
199
+ {
200
+ if (array_key_exists('appId', $this->_data)) { return $this->_data['appId']; }
201
+ return NULL;
202
+ }
203
+
204
+ /**
205
+ * Sets the appId field.
206
+ */
207
+ public function setAppId($appId)
208
+ {
209
+ $this->_data['appId'] = $appId;
210
+ }
211
+
212
+ /**
213
+ * Gets the appVer field.
214
+ */
215
+ public function getAppVer()
216
+ {
217
+ if (array_key_exists('appVer', $this->_data)) { return $this->_data['appVer']; }
218
+ return NULL;
219
+ }
220
+
221
+ /**
222
+ * Sets the appVer field.
223
+ */
224
+ public function setAppVer($appVer)
225
+ {
226
+ $this->_data['appVer'] = $appVer;
227
+ }
228
+
229
+ /**
230
+ * Gets the userId field.
231
+ */
232
+ public function getUserId()
233
+ {
234
+ if (array_key_exists('userId', $this->_data)) { return $this->_data['userId']; }
235
+ return NULL;
236
+ }
237
+
238
+ /**
239
+ * Sets the userId field.
240
+ */
241
+ public function setUserId($userId)
242
+ {
243
+ $this->_data['userId'] = $userId;
244
+ }
245
+
246
+ /**
247
+ * Gets the tags field.
248
+ */
249
+ public function getTags()
250
+ {
251
+ if (array_key_exists('tags', $this->_data)) { return $this->_data['tags']; }
252
+ return NULL;
253
+ }
254
+
255
+ /**
256
+ * Sets the tags field.
257
+ */
258
+ public function setTags($tags)
259
+ {
260
+ $this->_data['tags'] = $tags;
261
+ }
262
+
263
+ /**
264
+ * Gets the data field.
265
+ */
266
+ public function getData()
267
+ {
268
+ if (array_key_exists('data', $this->_data)) { return $this->_data['data']; }
269
+ return NULL;
270
+ }
271
+
272
+ /**
273
+ * Sets the data field.
274
+ */
275
+ public function setData($data)
276
+ {
277
+ $this->_data['data'] = $data;
278
+ }
279
+
280
+ /**
281
+ * Overrides JSON serialization for this class.
282
+ */
283
+ public function jsonSerialize()
284
+ {
285
+ return Utils::removeEmptyValues($this->_data);
286
+ }
287
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Event_Data.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Event_Data.
6
+ */
7
+ class Event_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new EventData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.Event';
30
+ $this->_dataTypeName = 'EventData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['name'] = NULL;
33
+ }
34
+
35
+ /**
36
+ * Gets the envelopeTypeName field.
37
+ */
38
+ public function getEnvelopeTypeName()
39
+ {
40
+ return $this->_envelopeTypeName;
41
+ }
42
+
43
+ /**
44
+ * Gets the dataTypeName field.
45
+ */
46
+ public function getDataTypeName()
47
+ {
48
+ return $this->_dataTypeName;
49
+ }
50
+
51
+ /**
52
+ * Gets the ver field.
53
+ */
54
+ public function getVer()
55
+ {
56
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
57
+ return NULL;
58
+ }
59
+
60
+ /**
61
+ * Sets the ver field.
62
+ */
63
+ public function setVer($ver)
64
+ {
65
+ $this->_data['ver'] = $ver;
66
+ }
67
+
68
+ /**
69
+ * Gets the name field.
70
+ */
71
+ public function getName()
72
+ {
73
+ if (array_key_exists('name', $this->_data)) { return $this->_data['name']; }
74
+ return NULL;
75
+ }
76
+
77
+ /**
78
+ * Sets the name field.
79
+ */
80
+ public function setName($name)
81
+ {
82
+ $this->_data['name'] = $name;
83
+ }
84
+
85
+ /**
86
+ * Gets the properties field.
87
+ */
88
+ public function getProperties()
89
+ {
90
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
91
+ return NULL;
92
+ }
93
+
94
+ /**
95
+ * Sets the properties field.
96
+ */
97
+ public function setProperties($properties)
98
+ {
99
+ $this->_data['properties'] = $properties;
100
+ }
101
+
102
+ /**
103
+ * Gets the measurements field.
104
+ */
105
+ public function getMeasurements()
106
+ {
107
+ if (array_key_exists('measurements', $this->_data)) { return $this->_data['measurements']; }
108
+ return NULL;
109
+ }
110
+
111
+ /**
112
+ * Sets the measurements field.
113
+ */
114
+ public function setMeasurements($measurements)
115
+ {
116
+ $this->_data['measurements'] = $measurements;
117
+ }
118
+
119
+ /**
120
+ * Overrides JSON serialization for this class.
121
+ */
122
+ public function jsonSerialize()
123
+ {
124
+ return Utils::removeEmptyValues($this->_data);
125
+ }
126
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Exception_Data.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Exception_Data.
6
+ */
7
+ class Exception_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new ExceptionData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.Exception';
30
+ $this->_dataTypeName = 'ExceptionData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['handledAt'] = NULL;
33
+ $this->_data['exceptions'] = [];
34
+ }
35
+
36
+ /**
37
+ * Gets the envelopeTypeName field.
38
+ */
39
+ public function getEnvelopeTypeName()
40
+ {
41
+ return $this->_envelopeTypeName;
42
+ }
43
+
44
+ /**
45
+ * Gets the dataTypeName field.
46
+ */
47
+ public function getDataTypeName()
48
+ {
49
+ return $this->_dataTypeName;
50
+ }
51
+
52
+ /**
53
+ * Gets the ver field.
54
+ */
55
+ public function getVer()
56
+ {
57
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
58
+ return NULL;
59
+ }
60
+
61
+ /**
62
+ * Sets the ver field.
63
+ */
64
+ public function setVer($ver)
65
+ {
66
+ $this->_data['ver'] = $ver;
67
+ }
68
+
69
+ /**
70
+ * Gets the handledAt field.
71
+ */
72
+ public function getHandledAt()
73
+ {
74
+ if (array_key_exists('handledAt', $this->_data)) { return $this->_data['handledAt']; }
75
+ return NULL;
76
+ }
77
+
78
+ /**
79
+ * Sets the handledAt field.
80
+ */
81
+ public function setHandledAt($handledAt)
82
+ {
83
+ $this->_data['handledAt'] = $handledAt;
84
+ }
85
+
86
+ /**
87
+ * Gets the exceptions field.
88
+ */
89
+ public function getExceptions()
90
+ {
91
+ if (array_key_exists('exceptions', $this->_data)) { return $this->_data['exceptions']; }
92
+ return NULL;
93
+ }
94
+
95
+ /**
96
+ * Sets the exceptions field.
97
+ */
98
+ public function setExceptions($exceptions)
99
+ {
100
+ $this->_data['exceptions'] = $exceptions;
101
+ }
102
+
103
+ /**
104
+ * Gets the severityLevel field.
105
+ */
106
+ public function getSeverityLevel()
107
+ {
108
+ if (array_key_exists('severityLevel', $this->_data)) { return $this->_data['severityLevel']; }
109
+ return NULL;
110
+ }
111
+
112
+ /**
113
+ * Sets the severityLevel field.
114
+ */
115
+ public function setSeverityLevel($severityLevel)
116
+ {
117
+ $this->_data['severityLevel'] = $severityLevel;
118
+ }
119
+
120
+ /**
121
+ * Gets the properties field.
122
+ */
123
+ public function getProperties()
124
+ {
125
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
126
+ return NULL;
127
+ }
128
+
129
+ /**
130
+ * Sets the properties field.
131
+ */
132
+ public function setProperties($properties)
133
+ {
134
+ $this->_data['properties'] = $properties;
135
+ }
136
+
137
+ /**
138
+ * Gets the measurements field.
139
+ */
140
+ public function getMeasurements()
141
+ {
142
+ if (array_key_exists('measurements', $this->_data)) { return $this->_data['measurements']; }
143
+ return NULL;
144
+ }
145
+
146
+ /**
147
+ * Sets the measurements field.
148
+ */
149
+ public function setMeasurements($measurements)
150
+ {
151
+ $this->_data['measurements'] = $measurements;
152
+ }
153
+
154
+ /**
155
+ * Overrides JSON serialization for this class.
156
+ */
157
+ public function jsonSerialize()
158
+ {
159
+ return Utils::removeEmptyValues($this->_data);
160
+ }
161
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Exception_Details.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Exception_Details.
6
+ */
7
+ class Exception_Details
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new ExceptionDetails.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data['typeName'] = NULL;
20
+ $this->_data['message'] = NULL;
21
+ $this->_data['hasFullStack'] = true;
22
+ }
23
+
24
+ /**
25
+ * Gets the id field.
26
+ */
27
+ public function getId()
28
+ {
29
+ if (array_key_exists('id', $this->_data)) { return $this->_data['id']; }
30
+ return NULL;
31
+ }
32
+
33
+ /**
34
+ * Sets the id field.
35
+ */
36
+ public function setId($id)
37
+ {
38
+ $this->_data['id'] = $id;
39
+ }
40
+
41
+ /**
42
+ * Gets the outerId field.
43
+ */
44
+ public function getOuterId()
45
+ {
46
+ if (array_key_exists('outerId', $this->_data)) { return $this->_data['outerId']; }
47
+ return NULL;
48
+ }
49
+
50
+ /**
51
+ * Sets the outerId field.
52
+ */
53
+ public function setOuterId($outerId)
54
+ {
55
+ $this->_data['outerId'] = $outerId;
56
+ }
57
+
58
+ /**
59
+ * Gets the typeName field.
60
+ */
61
+ public function getTypeName()
62
+ {
63
+ if (array_key_exists('typeName', $this->_data)) { return $this->_data['typeName']; }
64
+ return NULL;
65
+ }
66
+
67
+ /**
68
+ * Sets the typeName field.
69
+ */
70
+ public function setTypeName($typeName)
71
+ {
72
+ $this->_data['typeName'] = $typeName;
73
+ }
74
+
75
+ /**
76
+ * Gets the message field.
77
+ */
78
+ public function getMessage()
79
+ {
80
+ if (array_key_exists('message', $this->_data)) { return $this->_data['message']; }
81
+ return NULL;
82
+ }
83
+
84
+ /**
85
+ * Sets the message field.
86
+ */
87
+ public function setMessage($message)
88
+ {
89
+ $this->_data['message'] = $message;
90
+ }
91
+
92
+ /**
93
+ * Gets the hasFullStack field.
94
+ */
95
+ public function getHasFullStack()
96
+ {
97
+ if (array_key_exists('hasFullStack', $this->_data)) { return $this->_data['hasFullStack']; }
98
+ return NULL;
99
+ }
100
+
101
+ /**
102
+ * Sets the hasFullStack field.
103
+ */
104
+ public function setHasFullStack($hasFullStack)
105
+ {
106
+ $this->_data['hasFullStack'] = $hasFullStack;
107
+ }
108
+
109
+ /**
110
+ * Gets the stack field.
111
+ */
112
+ public function getStack()
113
+ {
114
+ if (array_key_exists('stack', $this->_data)) { return $this->_data['stack']; }
115
+ return NULL;
116
+ }
117
+
118
+ /**
119
+ * Sets the stack field.
120
+ */
121
+ public function setStack($stack)
122
+ {
123
+ $this->_data['stack'] = $stack;
124
+ }
125
+
126
+ /**
127
+ * Gets the parsedStack field.
128
+ */
129
+ public function getParsedStack()
130
+ {
131
+ if (array_key_exists('parsedStack', $this->_data)) { return $this->_data['parsedStack']; }
132
+ return NULL;
133
+ }
134
+
135
+ /**
136
+ * Sets the parsedStack field.
137
+ */
138
+ public function setParsedStack($parsedStack)
139
+ {
140
+ $this->_data['parsedStack'] = $parsedStack;
141
+ }
142
+
143
+ /**
144
+ * Overrides JSON serialization for this class.
145
+ */
146
+ public function jsonSerialize()
147
+ {
148
+ return Utils::removeEmptyValues($this->_data);
149
+ }
150
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Internal.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Internal.
6
+ */
7
+ class Internal
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Internal.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the sdkVersion field.
24
+ */
25
+ public function getSdkVersion()
26
+ {
27
+ if (array_key_exists('ai.internal.sdkVersion', $this->_data)) { return $this->_data['ai.internal.sdkVersion']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the sdkVersion field.
33
+ */
34
+ public function setSdkVersion($sdkVersion)
35
+ {
36
+ $this->_data['ai.internal.sdkVersion'] = $sdkVersion;
37
+ }
38
+
39
+ /**
40
+ * Gets the agentVersion field.
41
+ */
42
+ public function getAgentVersion()
43
+ {
44
+ if (array_key_exists('ai.internal.agentVersion', $this->_data)) { return $this->_data['ai.internal.agentVersion']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the agentVersion field.
50
+ */
51
+ public function setAgentVersion($agentVersion)
52
+ {
53
+ $this->_data['ai.internal.agentVersion'] = $agentVersion;
54
+ }
55
+
56
+ /**
57
+ * Overrides JSON serialization for this class.
58
+ */
59
+ public function jsonSerialize()
60
+ {
61
+ return Utils::removeEmptyValues($this->_data);
62
+ }
63
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Location.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Location.
6
+ */
7
+ class Location
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Location.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the ip field.
24
+ */
25
+ public function getIp()
26
+ {
27
+ if (array_key_exists('ai.location.ip', $this->_data)) { return $this->_data['ai.location.ip']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the ip field.
33
+ */
34
+ public function setIp($ip)
35
+ {
36
+ $this->_data['ai.location.ip'] = $ip;
37
+ }
38
+
39
+ /**
40
+ * Overrides JSON serialization for this class.
41
+ */
42
+ public function jsonSerialize()
43
+ {
44
+ return Utils::removeEmptyValues($this->_data);
45
+ }
46
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Message_Data.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Message_Data.
6
+ */
7
+ class Message_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new MessageData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.Message';
30
+ $this->_dataTypeName = 'MessageData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['message'] = NULL;
33
+ }
34
+
35
+ /**
36
+ * Gets the envelopeTypeName field.
37
+ */
38
+ public function getEnvelopeTypeName()
39
+ {
40
+ return $this->_envelopeTypeName;
41
+ }
42
+
43
+ /**
44
+ * Gets the dataTypeName field.
45
+ */
46
+ public function getDataTypeName()
47
+ {
48
+ return $this->_dataTypeName;
49
+ }
50
+
51
+ /**
52
+ * Gets the ver field.
53
+ */
54
+ public function getVer()
55
+ {
56
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
57
+ return NULL;
58
+ }
59
+
60
+ /**
61
+ * Sets the ver field.
62
+ */
63
+ public function setVer($ver)
64
+ {
65
+ $this->_data['ver'] = $ver;
66
+ }
67
+
68
+ /**
69
+ * Gets the message field.
70
+ */
71
+ public function getMessage()
72
+ {
73
+ if (array_key_exists('message', $this->_data)) { return $this->_data['message']; }
74
+ return NULL;
75
+ }
76
+
77
+ /**
78
+ * Sets the message field.
79
+ */
80
+ public function setMessage($message)
81
+ {
82
+ $this->_data['message'] = $message;
83
+ }
84
+
85
+ /**
86
+ * Gets the severityLevel field.
87
+ */
88
+ public function getSeverityLevel()
89
+ {
90
+ if (array_key_exists('severityLevel', $this->_data)) { return $this->_data['severityLevel']; }
91
+ return NULL;
92
+ }
93
+
94
+ /**
95
+ * Sets the severityLevel field.
96
+ */
97
+ public function setSeverityLevel($severityLevel)
98
+ {
99
+ $this->_data['severityLevel'] = $severityLevel;
100
+ }
101
+
102
+ /**
103
+ * Gets the properties field.
104
+ */
105
+ public function getProperties()
106
+ {
107
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
108
+ return NULL;
109
+ }
110
+
111
+ /**
112
+ * Sets the properties field.
113
+ */
114
+ public function setProperties($properties)
115
+ {
116
+ $this->_data['properties'] = $properties;
117
+ }
118
+
119
+ /**
120
+ * Overrides JSON serialization for this class.
121
+ */
122
+ public function jsonSerialize()
123
+ {
124
+ return Utils::removeEmptyValues($this->_data);
125
+ }
126
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Metric_Data.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Metric_Data.
6
+ */
7
+ class Metric_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new MetricData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.Metric';
30
+ $this->_dataTypeName = 'MetricData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['metrics'] = [];
33
+ }
34
+
35
+ /**
36
+ * Gets the envelopeTypeName field.
37
+ */
38
+ public function getEnvelopeTypeName()
39
+ {
40
+ return $this->_envelopeTypeName;
41
+ }
42
+
43
+ /**
44
+ * Gets the dataTypeName field.
45
+ */
46
+ public function getDataTypeName()
47
+ {
48
+ return $this->_dataTypeName;
49
+ }
50
+
51
+ /**
52
+ * Gets the ver field.
53
+ */
54
+ public function getVer()
55
+ {
56
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
57
+ return NULL;
58
+ }
59
+
60
+ /**
61
+ * Sets the ver field.
62
+ */
63
+ public function setVer($ver)
64
+ {
65
+ $this->_data['ver'] = $ver;
66
+ }
67
+
68
+ /**
69
+ * Gets the metrics field.
70
+ */
71
+ public function getMetrics()
72
+ {
73
+ if (array_key_exists('metrics', $this->_data)) { return $this->_data['metrics']; }
74
+ return NULL;
75
+ }
76
+
77
+ /**
78
+ * Sets the metrics field.
79
+ */
80
+ public function setMetrics($metrics)
81
+ {
82
+ $this->_data['metrics'] = $metrics;
83
+ }
84
+
85
+ /**
86
+ * Gets the properties field.
87
+ */
88
+ public function getProperties()
89
+ {
90
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
91
+ return NULL;
92
+ }
93
+
94
+ /**
95
+ * Sets the properties field.
96
+ */
97
+ public function setProperties($properties)
98
+ {
99
+ $this->_data['properties'] = $properties;
100
+ }
101
+
102
+ /**
103
+ * Overrides JSON serialization for this class.
104
+ */
105
+ public function jsonSerialize()
106
+ {
107
+ return Utils::removeEmptyValues($this->_data);
108
+ }
109
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Operation.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Operation.
6
+ */
7
+ class Operation
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Operation.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the id field.
24
+ */
25
+ public function getId()
26
+ {
27
+ if (array_key_exists('ai.operation.id', $this->_data)) { return $this->_data['ai.operation.id']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the id field.
33
+ */
34
+ public function setId($id)
35
+ {
36
+ $this->_data['ai.operation.id'] = $id;
37
+ }
38
+
39
+ /**
40
+ * Gets the name field.
41
+ */
42
+ public function getName()
43
+ {
44
+ if (array_key_exists('ai.operation.name', $this->_data)) { return $this->_data['ai.operation.name']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the name field.
50
+ */
51
+ public function setName($name)
52
+ {
53
+ $this->_data['ai.operation.name'] = $name;
54
+ }
55
+
56
+ /**
57
+ * Gets the parentId field.
58
+ */
59
+ public function getParentId()
60
+ {
61
+ if (array_key_exists('ai.operation.parentId', $this->_data)) { return $this->_data['ai.operation.parentId']; }
62
+ return NULL;
63
+ }
64
+
65
+ /**
66
+ * Sets the parentId field.
67
+ */
68
+ public function setParentId($parentId)
69
+ {
70
+ $this->_data['ai.operation.parentId'] = $parentId;
71
+ }
72
+
73
+ /**
74
+ * Gets the rootId field.
75
+ */
76
+ public function getRootId()
77
+ {
78
+ if (array_key_exists('ai.operation.rootId', $this->_data)) { return $this->_data['ai.operation.rootId']; }
79
+ return NULL;
80
+ }
81
+
82
+ /**
83
+ * Sets the rootId field.
84
+ */
85
+ public function setRootId($rootId)
86
+ {
87
+ $this->_data['ai.operation.rootId'] = $rootId;
88
+ }
89
+
90
+ /**
91
+ * Overrides JSON serialization for this class.
92
+ */
93
+ public function jsonSerialize()
94
+ {
95
+ return Utils::removeEmptyValues($this->_data);
96
+ }
97
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Page_View_Data.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Page_View_Data.
6
+ */
7
+ class Page_View_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new PageViewData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.PageView';
30
+ $this->_dataTypeName = 'PageViewData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['name'] = NULL;
33
+ }
34
+
35
+ /**
36
+ * Gets the envelopeTypeName field.
37
+ */
38
+ public function getEnvelopeTypeName()
39
+ {
40
+ return $this->_envelopeTypeName;
41
+ }
42
+
43
+ /**
44
+ * Gets the dataTypeName field.
45
+ */
46
+ public function getDataTypeName()
47
+ {
48
+ return $this->_dataTypeName;
49
+ }
50
+
51
+ /**
52
+ * Gets the ver field.
53
+ */
54
+ public function getVer()
55
+ {
56
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
57
+ return NULL;
58
+ }
59
+
60
+ /**
61
+ * Sets the ver field.
62
+ */
63
+ public function setVer($ver)
64
+ {
65
+ $this->_data['ver'] = $ver;
66
+ }
67
+
68
+ /**
69
+ * Gets the url field.
70
+ */
71
+ public function getUrl()
72
+ {
73
+ if (array_key_exists('url', $this->_data)) { return $this->_data['url']; }
74
+ return NULL;
75
+ }
76
+
77
+ /**
78
+ * Sets the url field.
79
+ */
80
+ public function setUrl($url)
81
+ {
82
+ $this->_data['url'] = $url;
83
+ }
84
+
85
+ /**
86
+ * Gets the name field.
87
+ */
88
+ public function getName()
89
+ {
90
+ if (array_key_exists('name', $this->_data)) { return $this->_data['name']; }
91
+ return NULL;
92
+ }
93
+
94
+ /**
95
+ * Sets the name field.
96
+ */
97
+ public function setName($name)
98
+ {
99
+ $this->_data['name'] = $name;
100
+ }
101
+
102
+ /**
103
+ * Gets the duration field.
104
+ */
105
+ public function getDuration()
106
+ {
107
+ if (array_key_exists('duration', $this->_data)) { return $this->_data['duration']; }
108
+ return NULL;
109
+ }
110
+
111
+ /**
112
+ * Sets the duration field.
113
+ */
114
+ public function setDuration($duration)
115
+ {
116
+ $this->_data['duration'] = var_export($duration, true);
117
+ }
118
+
119
+ /**
120
+ * Gets the properties field.
121
+ */
122
+ public function getProperties()
123
+ {
124
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
125
+ return NULL;
126
+ }
127
+
128
+ /**
129
+ * Sets the properties field.
130
+ */
131
+ public function setProperties($properties)
132
+ {
133
+ $this->_data['properties'] = $properties;
134
+ }
135
+
136
+ /**
137
+ * Gets the measurements field.
138
+ */
139
+ public function getMeasurements()
140
+ {
141
+ if (array_key_exists('measurements', $this->_data)) { return $this->_data['measurements']; }
142
+ return NULL;
143
+ }
144
+
145
+ /**
146
+ * Sets the measurements field.
147
+ */
148
+ public function setMeasurements($measurements)
149
+ {
150
+ $this->_data['measurements'] = $measurements;
151
+ }
152
+
153
+ /**
154
+ * Overrides JSON serialization for this class.
155
+ */
156
+ public function jsonSerialize()
157
+ {
158
+ return Utils::removeEmptyValues($this->_data);
159
+ }
160
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Request_Data.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Request_Data.
6
+ */
7
+ class Request_Data
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Needed to properly construct the JSON envelope.
16
+ */
17
+ private $_envelopeTypeName;
18
+
19
+ /**
20
+ * Needed to properly construct the JSON envelope.
21
+ */
22
+ private $_dataTypeName;
23
+
24
+ /**
25
+ * Creates a new RequestData.
26
+ */
27
+ function __construct()
28
+ {
29
+ $this->_envelopeTypeName = 'Microsoft.ApplicationInsights.Request';
30
+ $this->_dataTypeName = 'RequestData';
31
+ $this->_data['ver'] = 2;
32
+ $this->_data['id'] = NULL;
33
+ $this->_data['startTime'] = NULL;
34
+ $this->_data['duration'] = NULL;
35
+ $this->_data['responseCode'] = NULL;
36
+ $this->_data['success'] = NULL;
37
+ }
38
+
39
+ /**
40
+ * Gets the envelopeTypeName field.
41
+ */
42
+ public function getEnvelopeTypeName()
43
+ {
44
+ return $this->_envelopeTypeName;
45
+ }
46
+
47
+ /**
48
+ * Gets the dataTypeName field.
49
+ */
50
+ public function getDataTypeName()
51
+ {
52
+ return $this->_dataTypeName;
53
+ }
54
+
55
+ /**
56
+ * Gets the ver field.
57
+ */
58
+ public function getVer()
59
+ {
60
+ if (array_key_exists('ver', $this->_data)) { return $this->_data['ver']; }
61
+ return NULL;
62
+ }
63
+
64
+ /**
65
+ * Sets the ver field.
66
+ */
67
+ public function setVer($ver)
68
+ {
69
+ $this->_data['ver'] = $ver;
70
+ }
71
+
72
+ /**
73
+ * Gets the id field.
74
+ */
75
+ public function getId()
76
+ {
77
+ if (array_key_exists('id', $this->_data)) { return $this->_data['id']; }
78
+ return NULL;
79
+ }
80
+
81
+ /**
82
+ * Sets the id field.
83
+ */
84
+ public function setId($id)
85
+ {
86
+ $this->_data['id'] = (string)var_export($id, true);
87
+ }
88
+
89
+ /**
90
+ * Gets the name field.
91
+ */
92
+ public function getName()
93
+ {
94
+ if (array_key_exists('name', $this->_data)) { return $this->_data['name']; }
95
+ return NULL;
96
+ }
97
+
98
+ /**
99
+ * Sets the name field.
100
+ */
101
+ public function setName($name)
102
+ {
103
+ $this->_data['name'] = $name;
104
+ }
105
+
106
+ /**
107
+ * Gets the startTime field.
108
+ */
109
+ public function getStartTime()
110
+ {
111
+ if (array_key_exists('startTime', $this->_data)) { return $this->_data['startTime']; }
112
+ return NULL;
113
+ }
114
+
115
+ /**
116
+ * Sets the startTime field.
117
+ */
118
+ public function setStartTime($startTime)
119
+ {
120
+ $this->_data['startTime'] = $startTime;
121
+ }
122
+
123
+ /**
124
+ * Gets the duration field.
125
+ */
126
+ public function getDuration()
127
+ {
128
+ if (array_key_exists('duration', $this->_data)) { return $this->_data['duration']; }
129
+ return NULL;
130
+ }
131
+
132
+ /**
133
+ * Sets the duration field.
134
+ */
135
+ public function setDuration($duration)
136
+ {
137
+ $this->_data['duration'] = $duration;
138
+ }
139
+
140
+ /**
141
+ * Gets the responseCode field.
142
+ */
143
+ public function getResponseCode()
144
+ {
145
+ if (array_key_exists('responseCode', $this->_data)) { return $this->_data['responseCode']; }
146
+ return NULL;
147
+ }
148
+
149
+ /**
150
+ * Sets the responseCode field.
151
+ */
152
+ public function setResponseCode($responseCode)
153
+ {
154
+ $this->_data['responseCode'] = (string)var_export($responseCode, true);
155
+ }
156
+
157
+ /**
158
+ * Gets the success field.
159
+ */
160
+ public function getSuccess()
161
+ {
162
+ if (array_key_exists('success', $this->_data)) { return $this->_data['success']; }
163
+ return NULL;
164
+ }
165
+
166
+ /**
167
+ * Sets the success field.
168
+ */
169
+ public function setSuccess($success)
170
+ {
171
+ $this->_data['success'] = $success;
172
+ }
173
+
174
+ /**
175
+ * Gets the httpMethod field.
176
+ */
177
+ public function getHttpMethod()
178
+ {
179
+ if (array_key_exists('httpMethod', $this->_data)) { return $this->_data['httpMethod']; }
180
+ return NULL;
181
+ }
182
+
183
+ /**
184
+ * Sets the httpMethod field.
185
+ */
186
+ public function setHttpMethod($httpMethod)
187
+ {
188
+ $this->_data['httpMethod'] = $httpMethod;
189
+ }
190
+
191
+ /**
192
+ * Gets the url field.
193
+ */
194
+ public function getUrl()
195
+ {
196
+ if (array_key_exists('url', $this->_data)) { return $this->_data['url']; }
197
+ return NULL;
198
+ }
199
+
200
+ /**
201
+ * Sets the url field.
202
+ */
203
+ public function setUrl($url)
204
+ {
205
+ $this->_data['url'] = $url;
206
+ }
207
+
208
+ /**
209
+ * Gets the properties field.
210
+ */
211
+ public function getProperties()
212
+ {
213
+ if (array_key_exists('properties', $this->_data)) { return $this->_data['properties']; }
214
+ return NULL;
215
+ }
216
+
217
+ /**
218
+ * Sets the properties field.
219
+ */
220
+ public function setProperties($properties)
221
+ {
222
+ $this->_data['properties'] = $properties;
223
+ }
224
+
225
+ /**
226
+ * Gets the measurements field.
227
+ */
228
+ public function getMeasurements()
229
+ {
230
+ if (array_key_exists('measurements', $this->_data)) { return $this->_data['measurements']; }
231
+ return NULL;
232
+ }
233
+
234
+ /**
235
+ * Sets the measurements field.
236
+ */
237
+ public function setMeasurements($measurements)
238
+ {
239
+ $this->_data['measurements'] = $measurements;
240
+ }
241
+
242
+ /**
243
+ * Overrides JSON serialization for this class.
244
+ */
245
+ public function jsonSerialize()
246
+ {
247
+ return Utils::removeEmptyValues($this->_data);
248
+ }
249
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Session.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Session.
6
+ */
7
+ class Session
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new Session.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the id field.
24
+ */
25
+ public function getId()
26
+ {
27
+ if (array_key_exists('ai.session.id', $this->_data)) { return $this->_data['ai.session.id']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the id field.
33
+ */
34
+ public function setId($id)
35
+ {
36
+ $this->_data['ai.session.id'] = $id;
37
+ }
38
+
39
+ /**
40
+ * Gets the isFirst field.
41
+ */
42
+ public function getIsFirst()
43
+ {
44
+ if (array_key_exists('ai.session.isFirst', $this->_data)) { return $this->_data['ai.session.isFirst']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the isFirst field.
50
+ */
51
+ public function setIsFirst($isFirst)
52
+ {
53
+ $this->_data['ai.session.isFirst'] = var_export($isFirst, true);
54
+ }
55
+
56
+ /**
57
+ * Gets the isNew field.
58
+ */
59
+ public function getIsNew()
60
+ {
61
+ if (array_key_exists('ai.session.isNew', $this->_data)) { return $this->_data['ai.session.isNew']; }
62
+ return NULL;
63
+ }
64
+
65
+ /**
66
+ * Sets the isNew field.
67
+ */
68
+ public function setIsNew($isNew)
69
+ {
70
+ $this->_data['ai.session.isNew'] = var_export($isNew, true);;
71
+ }
72
+
73
+ /**
74
+ * Overrides JSON serialization for this class.
75
+ */
76
+ public function jsonSerialize()
77
+ {
78
+ return Utils::removeEmptyValues($this->_data);
79
+ }
80
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Stack_Frame.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type Stack_Frame.
6
+ */
7
+ class Stack_Frame
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new StackFrame.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data['level'] = NULL;
20
+ $this->_data['method'] = NULL;
21
+ }
22
+
23
+ /**
24
+ * Gets the level field.
25
+ */
26
+ public function getLevel()
27
+ {
28
+ if (array_key_exists('level', $this->_data)) { return $this->_data['level']; }
29
+ return NULL;
30
+ }
31
+
32
+ /**
33
+ * Sets the level field.
34
+ */
35
+ public function setLevel($level)
36
+ {
37
+ $this->_data['level'] = $level;
38
+ }
39
+
40
+ /**
41
+ * Gets the method field.
42
+ */
43
+ public function getMethod()
44
+ {
45
+ if (array_key_exists('method', $this->_data)) { return $this->_data['method']; }
46
+ return NULL;
47
+ }
48
+
49
+ /**
50
+ * Sets the method field.
51
+ */
52
+ public function setMethod($method)
53
+ {
54
+ $this->_data['method'] = $method;
55
+ }
56
+
57
+ /**
58
+ * Gets the assembly field.
59
+ */
60
+ public function getAssembly()
61
+ {
62
+ if (array_key_exists('assembly', $this->_data)) { return $this->_data['assembly']; }
63
+ return NULL;
64
+ }
65
+
66
+ /**
67
+ * Sets the assembly field.
68
+ */
69
+ public function setAssembly($assembly)
70
+ {
71
+ $this->_data['assembly'] = $assembly;
72
+ }
73
+
74
+ /**
75
+ * Gets the fileName field.
76
+ */
77
+ public function getFileName()
78
+ {
79
+ if (array_key_exists('fileName', $this->_data)) { return $this->_data['fileName']; }
80
+ return NULL;
81
+ }
82
+
83
+ /**
84
+ * Sets the fileName field.
85
+ */
86
+ public function setFileName($fileName)
87
+ {
88
+ $this->_data['fileName'] = $fileName;
89
+ }
90
+
91
+ /**
92
+ * Gets the line field.
93
+ */
94
+ public function getLine()
95
+ {
96
+ if (array_key_exists('line', $this->_data)) { return $this->_data['line']; }
97
+ return NULL;
98
+ }
99
+
100
+ /**
101
+ * Sets the line field.
102
+ */
103
+ public function setLine($line)
104
+ {
105
+ $this->_data['line'] = $line;
106
+ }
107
+
108
+ /**
109
+ * Overrides JSON serialization for this class.
110
+ */
111
+ public function jsonSerialize()
112
+ {
113
+ return Utils::removeEmptyValues($this->_data);
114
+ }
115
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/User.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Data contract class for type User.
6
+ */
7
+ class User
8
+ {
9
+ /**
10
+ * Data array that will store all the values.
11
+ */
12
+ private $_data;
13
+
14
+ /**
15
+ * Creates a new User.
16
+ */
17
+ function __construct()
18
+ {
19
+ $this->_data = array();
20
+ }
21
+
22
+ /**
23
+ * Gets the accountAcquisitionDate field.
24
+ */
25
+ public function getAccountAcquisitionDate()
26
+ {
27
+ if (array_key_exists('ai.user.accountAcquisitionDate', $this->_data)) { return $this->_data['ai.user.accountAcquisitionDate']; }
28
+ return NULL;
29
+ }
30
+
31
+ /**
32
+ * Sets the accountAcquisitionDate field.
33
+ */
34
+ public function setAccountAcquisitionDate($accountAcquisitionDate)
35
+ {
36
+ $this->_data['ai.user.accountAcquisitionDate'] = $accountAcquisitionDate;
37
+ }
38
+
39
+ /**
40
+ * Gets the accountId field.
41
+ */
42
+ public function getAccountId()
43
+ {
44
+ if (array_key_exists('ai.user.accountId', $this->_data)) { return $this->_data['ai.user.accountId']; }
45
+ return NULL;
46
+ }
47
+
48
+ /**
49
+ * Sets the accountId field.
50
+ */
51
+ public function setAccountId($accountId)
52
+ {
53
+ $this->_data['ai.user.accountId'] = $accountId;
54
+ }
55
+
56
+ /**
57
+ * Gets the userAgent field.
58
+ */
59
+ public function getUserAgent()
60
+ {
61
+ if (array_key_exists('ai.user.userAgent', $this->_data)) { return $this->_data['ai.user.userAgent']; }
62
+ return NULL;
63
+ }
64
+
65
+ /**
66
+ * Sets the userAgent field.
67
+ */
68
+ public function setUserAgent($userAgent)
69
+ {
70
+ $this->_data['ai.user.userAgent'] = $userAgent;
71
+ }
72
+
73
+ /**
74
+ * Gets the id field.
75
+ */
76
+ public function getId()
77
+ {
78
+ if (array_key_exists('ai.user.id', $this->_data)) { return $this->_data['ai.user.id']; }
79
+ return NULL;
80
+ }
81
+
82
+ /**
83
+ * Sets the id field.
84
+ */
85
+ public function setId($id)
86
+ {
87
+ $this->_data['ai.user.id'] = $id;
88
+ }
89
+
90
+ /**
91
+ * Overrides JSON serialization for this class.
92
+ */
93
+ public function jsonSerialize()
94
+ {
95
+ return Utils::removeEmptyValues($this->_data);
96
+ }
97
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Contracts/Utils.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Contains utilities for contract classes
6
+ */
7
+ class Utils
8
+ {
9
+ /**
10
+ * Removes NULL and empty collections
11
+ * @param array $sourceArray
12
+ * @return array
13
+ */
14
+ public static function removeEmptyValues($sourceArray)
15
+ {
16
+ $newArray = array();
17
+ foreach ($sourceArray as $key => $value)
18
+ {
19
+ if ((is_array($value) && sizeof($value) == 0) || ($value == NULL && is_bool($value) == false))
20
+ {
21
+ continue;
22
+ }
23
+ $newArray[$key] = $value;
24
+ }
25
+
26
+ return $newArray;
27
+ }
28
+
29
+ /**
30
+ * Serialization helper.
31
+ * @param array Items to serialize
32
+ * @return array JSON serialized items, nested
33
+ */
34
+ public static function getUnderlyingData($dataItems)
35
+ {
36
+ $queueToEncode = array();
37
+ foreach ($dataItems as $key => $dataItem)
38
+ {
39
+ if (is_object($dataItem) && method_exists($dataItem, 'jsonSerialize') == true)
40
+ {
41
+ $queueToEncode[$key] = Utils::getUnderlyingData($dataItem->jsonSerialize());
42
+ }
43
+ else if (is_array($dataItem))
44
+ {
45
+ $queueToEncode[$key] = Utils::getUnderlyingData($dataItem);
46
+ }
47
+ else
48
+ {
49
+ $queueToEncode[$key] = $dataItem;
50
+ }
51
+ }
52
+
53
+ return $queueToEncode;
54
+ }
55
+
56
+ /**
57
+ * Converts milliseconds to a timespan string as accepted by the backend
58
+ * @param int $milliseconds
59
+ * @return string
60
+ */
61
+ public static function convertMillisecondsToTimeSpan($milliseconds)
62
+ {
63
+ if ($milliseconds == NULL || $milliseconds < 0)
64
+ {
65
+ $milliseconds = 0;
66
+ }
67
+
68
+ $ms = $milliseconds % 1000;
69
+ $sec = floor($milliseconds / 1000) % 60;
70
+ $min = floor($milliseconds / (1000 * 60)) % 60;
71
+ $hour = floor($milliseconds / (1000 * 60 * 60)) % 24;
72
+
73
+ $ms = strlen($ms) == 1 ? '00' . $ms : (strlen($ms) === 2 ? "0" . $ms : $ms);
74
+ $sec = strlen($sec) < 2 ? '0' . $sec : $sec;
75
+ $min = strlen($min) < 2 ? '0' . $min : $min;
76
+ $hour = strlen($hour) < 2 ? '0' . $hour : $hour;
77
+
78
+ return $hour . ":" . $min . ":" . $sec . "." . $ms;
79
+ }
80
+
81
+ /**
82
+ * Returns the proper ISO string for Application Insights service to accept.
83
+ * @param mixed $time
84
+ * @return string
85
+ */
86
+ public static function returnISOStringForTime($time = null)
87
+ {
88
+ if ($time == NULL)
89
+ {
90
+ return gmdate('c') . 'Z';
91
+ }
92
+ else
93
+ {
94
+ return gmdate('c', $time) . 'Z';
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Returns a Guid on all flavors of PHP. Copied from the PHP manual: http://php.net/manual/en/function.com-create-guid.php
100
+ * @return mixed
101
+ */
102
+ public static function returnGuid()
103
+ {
104
+ if (function_exists('com_create_guid') === true)
105
+ {
106
+ return trim(com_create_guid(), '{}');
107
+ }
108
+
109
+ return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
110
+
111
+ }
112
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Channel/Telemetry_Channel.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel;
3
+
4
+ /**
5
+ * Responsible for managing a queue of telemetry items to send and sending them.
6
+ */
7
+ class Telemetry_Channel
8
+ {
9
+ /**
10
+ * The endpoint URL to send data to.
11
+ * @var string
12
+ */
13
+ private $_endpointUrl;
14
+
15
+ /**
16
+ * The queue of already serialized JSON objects to send.
17
+ * @var array
18
+ */
19
+ private $_queue;
20
+
21
+ /**
22
+ * Initializes a new Telemetry_Channel.
23
+ * @param string $endpointUrl Optional. Allows caller to override which endpoint to send data to.
24
+ */
25
+ function __construct($endpointUrl = 'https://dc.services.visualstudio.com/v2/track')
26
+ {
27
+ $this->_endpointUrl = $endpointUrl;
28
+ $this->_queue = array();
29
+ }
30
+
31
+ /**
32
+ * Returns the current URL this TelemetrySender will send to.
33
+ * @return string
34
+ */
35
+ public function getEndpointUrl()
36
+ {
37
+ return $this->_endpointUrl;
38
+ }
39
+
40
+ /**
41
+ * Sets the current URL this TelemetrySender will send to.
42
+ * @param string $endpointUrl
43
+ */
44
+ public function setEndpointUrl($endpointUrl)
45
+ {
46
+ $this->_endpointUrl = $endpointUrl;
47
+ }
48
+
49
+ /**
50
+ * Returns the current queue.
51
+ * @return array
52
+ */
53
+ public function getQueue()
54
+ {
55
+ return $this->_queue;
56
+ }
57
+
58
+ /**
59
+ * Sets the current queue.
60
+ * @param array $queue
61
+ */
62
+ public function setQueue($queue)
63
+ {
64
+ $this->_queue = $queue;
65
+ }
66
+
67
+ /**
68
+ * Summary of getSerializedQueue
69
+ * @return string JSON representation of queue.
70
+ */
71
+ public function getSerializedQueue()
72
+ {
73
+ $queueToEncode = array();
74
+ foreach ($this->_queue as $dataItem)
75
+ {
76
+ array_push($queueToEncode, Contracts\Utils::getUnderlyingData($dataItem->jsonSerialize()));
77
+ }
78
+
79
+ return json_encode($queueToEncode);
80
+ }
81
+
82
+ /**
83
+ * Writes the item into the sending queue for subsequent processing.
84
+ * @param mixed $data The telemetry item to send.
85
+ * @param \ApplicationInsights\Telemetry_Context $telemetryContext The context to use.
86
+ */
87
+ public function addToQueue($data, \ApplicationInsights\Telemetry_Context $telemetryContext)
88
+ {
89
+ // If no data or context provided, we just return to not cause upstream issues as a result of telemetry
90
+ if ($data == NULL || $telemetryContext == NULL)
91
+ {
92
+ return;
93
+ }
94
+
95
+ $envelope = new Contracts\Envelope();
96
+
97
+ // Main envelope properties
98
+ $envelope->setName($data->getEnvelopeTypeName());
99
+ $envelope->setTime(Contracts\Utils::returnISOStringForTime());
100
+
101
+ // Set the SDK version
102
+ $internalContext = new Contracts\Internal();
103
+ $internalContext->setSdkVersion('php:0.3.2');
104
+
105
+ // The instrumentation key to use
106
+ $envelope->setInstrumentationKey($telemetryContext->getInstrumentationKey());
107
+
108
+ // Copy all context into the Tags array
109
+ $envelope->setTags(array_merge($telemetryContext->getApplicationContext()->jsonSerialize(),
110
+ $telemetryContext->getDeviceContext()->jsonSerialize(),
111
+ $telemetryContext->getLocationContext()->jsonSerialize(),
112
+ $telemetryContext->getOperationContext()->jsonSerialize(),
113
+ $telemetryContext->getSessionContext()->jsonSerialize(),
114
+ $telemetryContext->getUserContext()->jsonSerialize(),
115
+ $internalContext->jsonSerialize()));
116
+
117
+ // Merge properties from global context to local context
118
+ $contextProperties = $telemetryContext->getProperties();
119
+ if (method_exists($data, 'getProperties') == true && $contextProperties != NULL && count($contextProperties) > 0)
120
+ {
121
+ $dataProperties = $data->getProperties();
122
+ if ($dataProperties == NULL)
123
+ {
124
+ $dataProperties = array();
125
+ }
126
+ foreach ($contextProperties as $key => $value)
127
+ {
128
+ if (array_key_exists($key, $dataProperties) == false)
129
+ {
130
+ $dataProperties[$key] = $value;
131
+ }
132
+ }
133
+ $data->setProperties($dataProperties);
134
+ }
135
+
136
+ // Embed the main data object
137
+ $envelope->setData(new Contracts\Data());
138
+ $envelope->getData()->setBaseType($data->getDataTypeName());
139
+ $envelope->getData()->setBaseData($data);
140
+
141
+ array_push($this->_queue, $envelope);
142
+ }
143
+
144
+ /**
145
+ * Summary of send
146
+ * @param mixed $telemetryItem
147
+ */
148
+ public function send()
149
+ {
150
+ if (count($this->_queue) == 0)
151
+ {
152
+ return;
153
+ }
154
+
155
+ $serializedTelemetryItem = $this->getSerializedQueue();
156
+
157
+ $headersArray = array('Accept' => 'application/json',
158
+ 'Content-Type' => 'application/json; charset=utf-8');
159
+
160
+ if (array_key_exists('HTTP_USER_AGENT', $_SERVER) == true)
161
+ {
162
+ $headersArray['User-Agent'] = $_SERVER['HTTP_USER_AGENT'];
163
+ }
164
+
165
+ $body = utf8_encode($serializedTelemetryItem);
166
+
167
+ if (class_exists('\GuzzleHttp\Client') == true)
168
+ {
169
+ // Standard case if properly pulled in composer dependencies
170
+
171
+ $client = new \GuzzleHttp\Client();
172
+
173
+ $client->post($this->_endpointUrl, array(
174
+ 'headers' => $headersArray,
175
+ 'body' => $body,
176
+ 'verify' => false /* If you want to verify, you can, but you will need to provide proper CA bundle. See http://guzzle.readthedocs.org/en/latest/clients.html#verify-option */
177
+ //,'proxy' => '127.0.0.1:8888' /* For Fiddler debugging */
178
+ ));
179
+ }
180
+ else if (function_exists('wp_remote_post'))
181
+ {
182
+ // Used in WordPress
183
+ wp_remote_post($this->_endpointUrl, array(
184
+ 'method' => 'POST',
185
+ 'blocking' => true,
186
+ 'headers' => $headersArray,
187
+ 'body' => $body
188
+ ));
189
+ }
190
+ }
191
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Current_Session.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights;
3
+
4
+ /**
5
+ * Main object used for managing sessions for other telemetry items.
6
+ */
7
+ class Current_Session
8
+ {
9
+ /**
10
+ * The current session id.
11
+ */
12
+ public $id;
13
+
14
+ /**
15
+ * When the session was created
16
+ */
17
+ public $sessionCreated;
18
+
19
+ /**
20
+ * When the session was last renewed
21
+ */
22
+ public $sessionLastRenewed;
23
+
24
+ /**
25
+ * Initializes a new Current_Session.
26
+ */
27
+ function __construct()
28
+ {
29
+ if (array_key_exists('ai_session', $_COOKIE))
30
+ {
31
+ $parts = explode('|', $_COOKIE['ai_session']);
32
+ $len = sizeof($parts);
33
+ if ($len > 0)
34
+ {
35
+ $this->id = $parts[0];
36
+ }
37
+
38
+ if ($len > 1)
39
+ {
40
+ $this->sessionCreated = strtotime($parts[1]);
41
+ }
42
+
43
+ if ($len > 2)
44
+ {
45
+ $this->sessionLastRenewed = strtotime($parts[2]);
46
+ }
47
+ }
48
+ }
49
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Current_User.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights;
3
+
4
+ /**
5
+ * Main object used for managing users for other telemetry items.
6
+ */
7
+ class Current_User
8
+ {
9
+ /**
10
+ * The current user id.
11
+ */
12
+ public $id;
13
+
14
+ /**
15
+ * Initializes a new Current_User.
16
+ */
17
+ function __construct()
18
+ {
19
+ if (array_key_exists('ai_user', $_COOKIE))
20
+ {
21
+ $parts = explode('|', $_COOKIE['ai_user']);
22
+ if (sizeof($parts) > 0)
23
+ {
24
+ $this->id = $parts[0];
25
+ }
26
+ }
27
+
28
+ if ($this->id == NULL)
29
+ {
30
+ $this->id = \ApplicationInsights\Channel\Contracts\Utils::returnGuid();
31
+ $_COOKIE['ai_user'] = $this->id;
32
+ }
33
+ }
34
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Telemetry_Client.php ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights;
3
+
4
+ /**
5
+ * Main object used for interacting with the Application Insights service.
6
+ */
7
+ class Telemetry_Client
8
+ {
9
+ /**
10
+ * The telemetry context this client will use
11
+ * @var \ApplicationInsights\Telemetry_Context
12
+ */
13
+ private $_context;
14
+
15
+ /**
16
+ * The telemetry channel this client will use
17
+ * @var \ApplicationInsights\Channel\Telemetry_Channel
18
+ */
19
+ private $_channel;
20
+
21
+ /**
22
+ * Initializes a new Telemetry_Client.
23
+ * @param \ApplicationInsights\Telemetry_Context $context
24
+ * @param \ApplicationInsights\Channel\Telemetry_Channel $channel
25
+ */
26
+ public function __construct(Telemetry_Context $context = NULL, Channel\Telemetry_Channel $channel = NULL)
27
+ {
28
+ $this->_context = ($context == NULL) ? new Telemetry_Context() : $context;
29
+ $this->_channel = ($channel == NULL) ? new Channel\Telemetry_Channel() : $channel;
30
+ }
31
+
32
+ /**
33
+ * Returns the Telemetry_Context this Telemetry_Client is using.
34
+ * @return \ApplicationInsights\Telemetry_Context
35
+ */
36
+ public function getContext()
37
+ {
38
+ return $this->_context;
39
+ }
40
+
41
+ /**
42
+ * Returns the Telemetry_Channel this Telemetry_Client is using.
43
+ * @return \ApplicationInsights\Channel\Telemetry_Channel
44
+ */
45
+ public function getChannel()
46
+ {
47
+ return $this->_channel;
48
+ }
49
+
50
+ /**
51
+ * Sends an Page_View_Data to the Application Insights service.
52
+ * @param string $name The friendly name of the page view.
53
+ * @param string $url The url of the page view.
54
+ * @param int duration The duration in milliseconds of the page view.
55
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
56
+ * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value.
57
+ */
58
+ public function trackPageView($name, $url, $duration = 0, $properties = NULL, $measurements = NULL)
59
+ {
60
+ $data = new Channel\Contracts\Page_View_Data();
61
+ $data->setName($name);
62
+ $data->setUrl($url);
63
+ $data->setDuration($duration);
64
+ if ($properties != NULL)
65
+ {
66
+ $data->setProperties($properties);
67
+ }
68
+ if ($measurements != NULL)
69
+ {
70
+ $data->setMeasurements($measurements);
71
+ }
72
+
73
+ $this->_channel->addToQueue($data, $this->_context);
74
+ }
75
+
76
+ /**
77
+ * Sends an Metric_Data to the Application Insights service.
78
+ * @param string $name Name of the metric.
79
+ * @param double $value Value of the metric.
80
+ * @param \ApplicationInsights\Channel\Data_Point_Type::Value $type The type of value being sent.
81
+ * @param int $count The number of samples.
82
+ * @param double $min The minimum of the samples.
83
+ * @param double $max The maximum of the samples.
84
+ * @param double $stdDev The standard deviation of the samples.
85
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
86
+ */
87
+ public function trackMetric($name, $value, $type = NULL, $count = NULL, $min = NULL, $max = NULL, $stdDev = NULL, $properties = NULL)
88
+ {
89
+ $dataPoiint = new Channel\Contracts\Data_Point();
90
+ $dataPoiint->setName($name);
91
+ $dataPoiint->setValue($value);
92
+ $dataPoiint->setKind($type == NULL ? Channel\Contracts\Data_Point_Type::Aggregation : $type);
93
+ $dataPoiint->setCount($count);
94
+ $dataPoiint->setMin($min);
95
+ $dataPoiint->setMax($max);
96
+ $dataPoiint->setStdDev($stdDev);
97
+
98
+ $data = new Channel\Contracts\Metric_Data();
99
+ $data->setMetrics(array($dataPoiint));
100
+ if ($properties != NULL)
101
+ {
102
+ $data->setProperties($properties);
103
+ }
104
+
105
+ $this->_channel->addToQueue($data, $this->_context);
106
+ }
107
+
108
+ /**
109
+ * Sends an Event_Data to the Application Insights service.
110
+ * @param string $name
111
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
112
+ * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value.
113
+ */
114
+ public function trackEvent($name, $properties = NULL, $measurements = NULL)
115
+ {
116
+ $data = new Channel\Contracts\Event_Data();
117
+ $data->setName($name);
118
+ if ($properties != NULL)
119
+ {
120
+ $data->setProperties($properties);
121
+ }
122
+ if ($measurements != NULL)
123
+ {
124
+ $data->setMeasurements($measurements);
125
+ }
126
+
127
+ $this->_channel->addToQueue($data, $this->_context);
128
+ }
129
+
130
+ /**
131
+ * Sends an Message_Data to the Application Insights service.
132
+ * @param string $message The trace message.
133
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
134
+ */
135
+ public function trackMessage($message, $properties = NULL)
136
+ {
137
+ $data = new Channel\Contracts\Message_Data();
138
+ $data->setMessage($message);
139
+
140
+ if ($properties != NULL)
141
+ {
142
+ $data->setProperties($properties);
143
+ }
144
+
145
+ $this->_channel->addToQueue($data, $this->_context);
146
+ }
147
+
148
+ /**
149
+ * Sends a Request_Data to the Application Insights service.
150
+ * @param string $name A friendly name of the request.
151
+ * @param string $url The url of the request.
152
+ * @param int $startTime The timestamp at which the request started.
153
+ * @param int $durationInMilliseconds The duration, in milliseconds, of the request.
154
+ * @param int $httpResponseCode The response code of the request.
155
+ * @param bool $isSuccessful Whether or not the request was successful.
156
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
157
+ * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value.
158
+ */
159
+ public function trackRequest($name, $url, $startTime, $durationInMilliseconds = 0, $httpResponseCode = 200, $isSuccessful = true, $properties = NULL, $measurements = NULL )
160
+ {
161
+ $this->endRequest($this->beginRequest($name, $url, $startTime), $durationInMilliseconds, $httpResponseCode, $isSuccessful, $properties, $measurements );
162
+ }
163
+
164
+ /**
165
+ * Begin a Request_Data to the Application Insights service. This request is not sent until an @see endRequest call is made, passing this request.
166
+ *
167
+ * @param string $name A friendly name of the request.
168
+ * @param string $url The url of the request.
169
+ * @param int $startTime The timestamp at which the request started.
170
+ * @return \ApplicationInsights\Channel\Contracts\Request_Data an initialized Request_Data, which can be sent by using @see endRequest
171
+ */
172
+ public function beginRequest($name, $url, $startTime )
173
+ {
174
+ $data = new Channel\Contracts\Request_Data();
175
+ $guid = \ApplicationInsights\Channel\Contracts\Utils::returnGuid();
176
+ $data->setId($guid);
177
+ $data->setName($name);
178
+ $data->setUrl($url);
179
+ $data->setStartTime(Channel\Contracts\Utils::returnISOStringForTime($startTime));
180
+
181
+ return $data;
182
+ }
183
+
184
+ /**
185
+ * Sends a Request_Data created by @see beginRequest to the Application Insights service.
186
+ * @param int $durationInMilliseconds The duration, in milliseconds, of the request.
187
+ * @param int $httpResponseCode The response code of the request.
188
+ * @param bool $isSuccessful Whether or not the request was successful.
189
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
190
+ * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value.
191
+ */
192
+ public function endRequest( Channel\Contracts\Request_Data $request, $durationInMilliseconds = 0, $httpResponseCode = 200, $isSuccessful = true, $properties = NULL, $measurements = NULL )
193
+ {
194
+ $request->setResponseCode($httpResponseCode);
195
+ $request->setSuccess($isSuccessful);
196
+
197
+ $request->setDuration(Channel\Contracts\Utils::convertMillisecondsToTimeSpan($durationInMilliseconds));
198
+
199
+ if ($properties != NULL)
200
+ {
201
+ $request->setProperties($properties);
202
+ }
203
+
204
+ if ($measurements != NULL)
205
+ {
206
+ $request->setMeasurements($measurements);
207
+ }
208
+
209
+ $this->_channel->addToQueue($request, $this->_context);
210
+ }
211
+
212
+ /**
213
+ * Sends an Exception_Data to the Application Insights service.
214
+ * @param \Exception $ex The exception to send
215
+ * @param array $properties An array of name to value pairs. Use the name as the index and any string as the value.
216
+ * @param array $measurements An array of name to double pairs. Use the name as the index and any double as the value.
217
+ */
218
+ public function trackException(\Exception $ex, $properties = NULL, $measurements = NULL)
219
+ {
220
+ $details = new Channel\Contracts\Exception_Details();
221
+ $details->setId(1);
222
+ $details->setOuterId(0);
223
+ $details->setTypeName(get_class($ex));
224
+ $details->setMessage($ex->getMessage().' in '.$ex->getFile().' on line '.$ex->getLine());
225
+ $details->setHasFullStack(true);
226
+
227
+ $stackFrames = array();
228
+
229
+ // First stack frame is in the root exception
230
+ $frameCounter = 0;
231
+ foreach ($ex->getTrace() as $currentFrame)
232
+ {
233
+ $stackFrame = new Channel\Contracts\Stack_Frame();
234
+ if (array_key_exists('class', $currentFrame) == true)
235
+ {
236
+ $stackFrame->setAssembly($currentFrame['class']);
237
+ }
238
+ if (array_key_exists('file', $currentFrame) == true)
239
+ {
240
+ $stackFrame->setFileName($currentFrame['file']);
241
+ }
242
+ if (array_key_exists('line', $currentFrame) == true)
243
+ {
244
+ $stackFrame->setLine($currentFrame['line']);
245
+ }
246
+ if (array_key_exists('function', $currentFrame) == true)
247
+ {
248
+ $stackFrame->setMethod($currentFrame['function']);
249
+ }
250
+
251
+ // Make it a string to force serialization of zero
252
+ $stackFrame->setLevel(''.$frameCounter);
253
+
254
+ array_unshift($stackFrames, $stackFrame);
255
+ $frameCounter++;
256
+ }
257
+
258
+ $details->setParsedStack($stackFrames);
259
+
260
+ $data = new Channel\Contracts\Exception_Data();
261
+ $data->setHandledAt('UserCode');
262
+ $data->setExceptions(array($details));
263
+
264
+ if ($properties != NULL)
265
+ {
266
+ $data->setProperties($properties);
267
+ }
268
+
269
+ if ($measurements != NULL)
270
+ {
271
+ $data->setMeasurements($measurements);
272
+ }
273
+
274
+ $this->_channel->addToQueue($data, $this->_context);
275
+ }
276
+
277
+ /**
278
+ * Flushes the underlying Telemetry_Channel queue.
279
+ */
280
+ public function flush()
281
+ {
282
+ $this->_channel->send();
283
+ $this->_channel->setQueue([]);
284
+ }
285
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Telemetry_Context.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights;
3
+
4
+ /**
5
+ * Responsible for managing the context to send along with all telemetry items.
6
+ */
7
+ class Telemetry_Context
8
+ {
9
+ /**
10
+ * The instrumentation key
11
+ * @var string (Guid)
12
+ */
13
+ private $_instrumentationKey;
14
+
15
+ /**
16
+ * The device context
17
+ * @var \ApplicationInsights\Channel\Contracts\Device
18
+ */
19
+ private $_deviceContext;
20
+
21
+ /**
22
+ * The application context
23
+ * @var \ApplicationInsights\Channel\Contracts\Application
24
+ */
25
+ private $_applicationContext;
26
+
27
+ /**
28
+ * The user context
29
+ * @var \ApplicationInsights\Channel\Contracts\User
30
+ */
31
+ private $_userContext;
32
+
33
+ /**
34
+ * The location context
35
+ * @var \ApplicationInsights\Channel\Contracts\Location
36
+ */
37
+ private $_locationContext;
38
+
39
+ /**
40
+ * The operation context
41
+ * @var \ApplicationInsights\Channel\Contracts\Operation
42
+ */
43
+ private $_operationContext;
44
+
45
+ /**
46
+ * The session context
47
+ * @var \ApplicationInsights\Channel\Contracts\Session
48
+ */
49
+ private $_sessionContext;
50
+
51
+ /**
52
+ * Additional custom properties array.
53
+ * @var array Additional properties (name/value pairs) to append as custom properties to all telemetry.
54
+ */
55
+ private $_properties;
56
+
57
+ /**
58
+ * Initializes a new TelemetryContext.
59
+ */
60
+ function __construct()
61
+ {
62
+ $this->_deviceContext = new Channel\Contracts\Device();
63
+ $this->_applicationContext = new Channel\Contracts\Application();
64
+ $this->_userContext = new Channel\Contracts\User();
65
+ $this->_locationContext = new Channel\Contracts\Location();
66
+ $this->_operationContext = new Channel\Contracts\Operation();
67
+ $this->_sessionContext = new Channel\Contracts\Session();
68
+ $this->_properties = array();
69
+
70
+ // Initialize user id
71
+ $currentUser = new Current_User();
72
+ $this->_userContext->setId($currentUser->id);
73
+
74
+ // Initialize session id
75
+ $currentSession = new Current_Session();
76
+ $this->_sessionContext->setId($currentSession->id);
77
+
78
+ // Initialize client ip
79
+ if (array_key_exists('REMOTE_ADDR', $_SERVER) && sizeof(explode('.', $_SERVER['REMOTE_ADDR'])) >= 4)
80
+ {
81
+ $this->_locationContext->setIp($_SERVER['REMOTE_ADDR']);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * The instrumentation key for your Application Insights application.
87
+ * @return string (Guid)
88
+ */
89
+ public function getInstrumentationKey()
90
+ {
91
+ return $this->_instrumentationKey;
92
+ }
93
+
94
+ /**
95
+ * Sets the instrumetation key on the context. This is the key for you application in Application Insights.
96
+ * @param string $instrumentationKey (Guid)
97
+ */
98
+ public function setInstrumentationKey($instrumentationKey)
99
+ {
100
+ $this->_instrumentationKey = $instrumentationKey;
101
+ }
102
+
103
+ /**
104
+ * The device context object. Allows you to set properties that will be attached to all telemetry about the device.
105
+ * @return \ApplicationInsights\Channel\Contracts\Device
106
+ */
107
+ public function getDeviceContext()
108
+ {
109
+ return $this->_deviceContext;
110
+ }
111
+
112
+ /**
113
+ * Sets device context object. Allows you to set properties that will be attached to all telemetry about the device.
114
+ * @param \ApplicationInsights\Channel\Contracts\Device $deviceContext
115
+ */
116
+ public function setDeviceContext(Channel\Contracts\Device $deviceContext)
117
+ {
118
+ $this->_deviceContext = $deviceContext;
119
+ }
120
+
121
+ /**
122
+ * The application context object. Allows you to set properties that will be attached to all telemetry about the application.
123
+ * @return \ApplicationInsights\Channel\Contracts\Application
124
+ */
125
+ public function getApplicationContext()
126
+ {
127
+ return $this->_applicationContext;
128
+ }
129
+
130
+ /**
131
+ * Sets application context object. Allows you to set properties that will be attached to all telemetry about the application.
132
+ * @param \ApplicationInsights\Channel\Contracts\Application $applicationContext
133
+ */
134
+ public function setApplicationContext(Channel\Contracts\Application $applicationContext)
135
+ {
136
+ $this->_applicationContext = $applicationContext;
137
+ }
138
+
139
+ /**
140
+ * The user context object. Allows you to set properties that will be attached to all telemetry about the user.
141
+ * @return \ApplicationInsights\Channel\Contracts\User
142
+ */
143
+ public function getUserContext()
144
+ {
145
+ return $this->_userContext;
146
+ }
147
+
148
+ /**
149
+ * Set user context object. Allows you to set properties that will be attached to all telemetry about the user.
150
+ * @param \ApplicationInsights\Channel\Contracts\User $userContext
151
+ */
152
+ public function setUserContext(Channel\Contracts\User $userContext)
153
+ {
154
+ $this->_userContext = $userContext;
155
+ }
156
+
157
+ /**
158
+ * The location context object. Allows you to set properties that will be attached to all telemetry about the location.
159
+ * @return \ApplicationInsights\Channel\Contracts\Location
160
+ */
161
+ public function getLocationContext()
162
+ {
163
+ return $this->_locationContext;
164
+ }
165
+
166
+ /**
167
+ * Set location context object. Allows you to set properties that will be attached to all telemetry about the location.
168
+ * @param \ApplicationInsights\Channel\Contracts\Location $locationContext
169
+ */
170
+ public function setLocationContext(Channel\Contracts\Location $locationContext)
171
+ {
172
+ $this->_locationContext = $locationContext;
173
+ }
174
+
175
+ /**
176
+ * The operation context object. Allows you to set properties that will be attached to all telemetry about the operation.
177
+ * @return \ApplicationInsights\Channel\Contracts\Operation
178
+ */
179
+ public function getOperationContext()
180
+ {
181
+ return $this->_operationContext;
182
+ }
183
+
184
+ /**
185
+ * Set operation context object. Allows you to set properties that will be attached to all telemetry about the operation.
186
+ * @param \ApplicationInsights\Channel\Contracts\Operation $operationContext
187
+ */
188
+ public function setOperationContext(Channel\Contracts\Operation $operationContext)
189
+ {
190
+ $this->_operationContext = $operationContext;
191
+ }
192
+
193
+ /**
194
+ * The session context object. Allows you to set properties that will be attached to all telemetry about the session.
195
+ * @return \ApplicationInsights\Channel\Contracts\Session
196
+ */
197
+ public function getSessionContext()
198
+ {
199
+ return $this->_sessionContext;
200
+ }
201
+
202
+ /**
203
+ * Set session context object. Allows you to set properties that will be attached to all telemetry about the session.
204
+ * @param \ApplicationInsights\Channel\Contracts\Session $sessionContext
205
+ */
206
+ public function setSessionContext(Channel\Contracts\Session $sessionContext)
207
+ {
208
+ $this->_sessionContext = $sessionContext;
209
+ }
210
+
211
+ /**
212
+ * Get the additional custom properties array.
213
+ * @return array Additional properties (name/value pairs) to append as custom properties to all telemetry.
214
+ */
215
+ public function getProperties()
216
+ {
217
+ return $this->_properties;
218
+ }
219
+
220
+ /**
221
+ * Set the additional custom properties array.
222
+ * @param array $properties Additional properties (name/value pairs) to append as custom properties to all telemetry.
223
+ */
224
+ public function setProperties($properties)
225
+ {
226
+ $this->_properties = $properties;
227
+ }
228
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Bootstrap.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ require_once 'vendor/autoload.php';
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Channel/Contracts/Utils_Test.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Contracts;
3
+
4
+ /**
5
+ * Contains tests for Utils class
6
+ */
7
+ class Utils_Test extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testConvertMillisecondsToTimeSpan()
10
+ {
11
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(0), "00:00:00.000");
12
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(1), "00:00:00.001", "milliseconds digit 1");
13
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(10), "00:00:00.010", "milliseconds digit 2");
14
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(100), "00:00:00.100", "milliseconds digit 3");
15
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(1 * 1000), "00:00:01.000", "seconds digit 1");
16
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(10 * 1000), "00:00:10.000", "seconds digit 2");
17
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(1 * 60 * 1000), "00:01:00.000", "minutes digit 1");
18
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(10 * 60 * 1000), "00:10:00.000", "minutes digit 2");
19
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(1 * 60 * 60 * 1000), "01:00:00.000", "hours digit 1");
20
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(10 * 60 * 60 * 1000), "10:00:00.000", "hours digit 2");
21
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(24 * 60 * 60 * 1000), "00:00:00.000", "hours overflow");
22
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(11 * 3600000 + 11 * 60000 + 11111), "11:11:11.111", "all digits");
23
+
24
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(""), "00:00:00.000", "invalid input");
25
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan("'"), "00:00:00.000", "invalid input");
26
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(NULL), "00:00:00.000", "invalid input");
27
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan([]), "00:00:00.000", "invalid input");
28
+ $this->assertEquals(Utils::convertMillisecondsToTimeSpan(-1), "00:00:00.000", "invalid input");
29
+
30
+ }
31
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Channel/Telemetry_Channel_Test.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Channel\Tests;
3
+
4
+ /**
5
+ * Contains tests for TelemetrySender class
6
+ */
7
+ class Telemetry_Channel_Test extends \PHPUnit_Framework_TestCase
8
+ {
9
+ public function testConstructor()
10
+ {
11
+ $telemetryChannel = new \ApplicationInsights\Channel\Telemetry_Channel();
12
+ $this->assertEquals($telemetryChannel->getEndpointUrl(), 'https://dc.services.visualstudio.com/v2/track', 'Default Endpoint URL is incorrect.');
13
+ $this->assertEquals($telemetryChannel->getQueue(), [], 'Queue should be empty by default.');
14
+ }
15
+
16
+ public function testEndpointUrl()
17
+ {
18
+ $telemetryChannel = new \ApplicationInsights\Channel\Telemetry_Channel();
19
+ $telemetryChannel->setEndpointUrl('http://foo.com');
20
+ $this->assertEquals($telemetryChannel->getEndpointUrl(), 'http://foo.com');
21
+ }
22
+
23
+ public function testQueue()
24
+ {
25
+ $telemetryChannel = new \ApplicationInsights\Channel\Telemetry_Channel();
26
+ $telemetryChannel->setQueue([42, 42, 42]);
27
+ $this->assertEquals($telemetryChannel->getQueue(), [42, 42, 42]);
28
+ }
29
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Current_Session_Test.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Tests;
3
+
4
+ /**
5
+ * Contains tests for Current_Session class
6
+ */
7
+ class Current_Session_Test extends \PHPUnit_Framework_TestCase
8
+ {
9
+ private $sessionId;
10
+ private $sessionCreatedTime;
11
+ private $sessionLastRenewedTime;
12
+
13
+ protected function setUp()
14
+ {
15
+ $this->sessionId = \ApplicationInsights\Channel\Contracts\Utils::returnGuid();
16
+ $this->sessionCreatedTime = time();
17
+ $this->sessionLastRenewedTime = time() - 10000;
18
+ Utils::setSessionCookie($this->sessionId, $this->sessionCreatedTime, $this->sessionLastRenewedTime);
19
+ }
20
+
21
+ protected function tearDown()
22
+ {
23
+ Utils::clearSessionCookie();
24
+ }
25
+
26
+ /**
27
+ * Verifies the object is constructed properly.
28
+ */
29
+ public function testConstructor()
30
+ {
31
+ $currentSession = new \ApplicationInsights\Current_Session();
32
+
33
+ $this->assertEquals($currentSession->id, $this->sessionId);
34
+ $this->assertEquals($currentSession->sessionCreated, $this->sessionCreatedTime);
35
+ $this->assertEquals($currentSession->sessionLastRenewed, $this->sessionLastRenewedTime);
36
+ }
37
+
38
+ /**
39
+ * Verifies the object is constructed properly.
40
+ */
41
+ public function testConstructorWithNoCookie()
42
+ {
43
+ Utils::clearSessionCookie();
44
+ $currentSession = new \ApplicationInsights\Current_Session();
45
+
46
+ $this->assertEquals($currentSession->id, NULL);
47
+ $this->assertEquals($currentSession->sessionCreated, NULL);
48
+ $this->assertEquals($currentSession->sessionLastRenewed, NULL);
49
+ }
50
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Current_User_Test.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Tests;
3
+
4
+ /**
5
+ * Contains tests for Current_User class
6
+ */
7
+ class Current_User_Test extends \PHPUnit_Framework_TestCase
8
+ {
9
+ private $userId;
10
+
11
+ protected function setUp()
12
+ {
13
+ $this->userId = \ApplicationInsights\Channel\Contracts\Utils::returnGuid();
14
+ Utils::setUserCookie($this->userId);
15
+ }
16
+
17
+ protected function tearDown()
18
+ {
19
+ Utils::clearUserCookie();
20
+ }
21
+
22
+ /**
23
+ * Verifies the object is constructed properly.
24
+ */
25
+ public function testConstructor()
26
+ {
27
+ $currentUser = new \ApplicationInsights\Current_User();
28
+
29
+ $this->assertEquals($currentUser->id, $this->userId);
30
+ }
31
+
32
+ /**
33
+ * Verifies the object is constructed properly.
34
+ */
35
+ public function testConstructorWithNoCookie()
36
+ {
37
+ Utils::clearUserCookie();
38
+ $currentUser = new \ApplicationInsights\Current_User();
39
+
40
+ $this->assertTrue($currentUser->id != NULL && $currentUser->id != $this->userId);
41
+ }
42
+
43
+ }
app/code/community/VeInteractive/VePlatform/vendor/microsoft/application-insights/ApplicationInsights/Tests/Telemetry_Client_Test.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ApplicationInsights\Tests;
3
+
4
+ /**
5
+ * Contains tests for Telemetry_Client class
6
+ */
7
+ class Telemetry_Client_Test extends \PHPUnit_Framework_TestCase
8
+ {
9
+ private $_telemetryClient;
10
+
11
+ protected function setUp()
12
+ {
13
+ $this->_telemetryClient = new \ApplicationInsights\Telemetry_Client();
14
+
15
+ $context = $this->_telemetryClient->getContext();
16
+
17
+ $context->setInstrumentationKey(Utils::getTestInstrumentationKey());
18
+ $context->setApplicationContext(Utils::getSampleApplicationContext());
19
+ $context->setDeviceContext(Utils::getSampleDeviceContext());
20
+ $context->setLocationContext(Utils::getSampleLocationContext());
21
+ $context->setOperationContext(Utils::getSampleOperationContext());
22
+ $context->setSessionContext(Utils::getSampleSessionContext());
23
+ $context->setUserContext(Utils::getSampleUserContext());
24
+
25
+ $context->setProperties(Utils::getSampleCustomProperties());
26
+ }
27
+
28
+ /**
29
+ * Tests a completely filled exception.
30
+ *
31
+ * Ensure this method doesn't move in the source, if it does, the test will fail and needs to have a line number adjusted.
32
+ */
33
+ public function testCompleteException()
34
+ {
35
+ try
36
+ {
37
+ Utils::throwNestedException(3);
38
+ }
39
+ catch (\Exception $ex)
40
+ {
41
+ $this->_telemetryClient->trackException($ex, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
42
+ }
43
+
44
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
45
+ $queue = $this->adjustDataInQueue($queue);
46
+
47
+ $searchStrings = array("\\");
48
+ $replaceStrings = array("\\\\");
49
+
50
+ $expectedString = str_replace($searchStrings, $replaceStrings, '[{"ver":1,"name":"Microsoft.ApplicationInsights.Exception","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1/1/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"handledAt":"UserCode","exceptions":[{"typeName":"Exception","message":"testException in G:\\GitHub\\AppInsights-PHP\\ApplicationInsights\\Tests\\Utils.php on line 130","hasFullStack":true,"id":1,"parsedStack":[{"level":"14","method":"main","assembly":"PHPUnit_TextUI_Command","fileName":"C:\\Users\\jakubo\\AppData\\Local\\Microsoft\\VisualStudio\\12.0\\Extensions\\DEVSENSE\\PHP Tools for Visual Studio 2013 1.14.5747\\phpunit-3.7.phar","line":612},{"level":"13","method":"run","assembly":"PHPUnit_TextUI_Command","fileName":"phar://C:/Users/jakubo/AppData/Local/Microsoft/VisualStudio/12.0/Extensions/DEVSENSE/PHP Tools for Visual Studio 2013 1.14.5747/phpunit-3.7.phar/phpunit/TextUI/Command.php","line":129},{"level":"12","method":"doRun","assembly":"PHPUnit_TextUI_TestRunner","fileName":"phar://C:/Users/jakubo/AppData/Local/Microsoft/VisualStudio/12.0/Extensions/DEVSENSE/PHP Tools for Visual Studio 2013 1.14.5747/phpunit-3.7.phar/phpunit/TextUI/Command.php","line":176},{"level":"11","method":"run","assembly":"PHPUnit_Framework_TestSuite","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\TextUI\\TestRunner.php","line":423},{"level":"10","method":"run","assembly":"PHPUnit_Framework_TestSuite","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestSuite.php","line":751},{"level":"9","method":"run","assembly":"PHPUnit_Framework_TestCase","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestSuite.php","line":751},{"level":"8","method":"run","assembly":"PHPUnit_Framework_TestResult","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestCase.php","line":612},{"level":"7","method":"runBare","assembly":"PHPUnit_Framework_TestCase","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestResult.php","line":643},{"level":"6","method":"runTest","assembly":"PHPUnit_Framework_TestCase","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestCase.php","line":766},{"level":"5","method":"invokeArgs","assembly":"ReflectionMethod","fileName":"G:\\GitHub\\AppInsights-PHP\\vendor\\phpunit\\phpunit\\src\\Framework\\TestCase.php","line":881},{"level":"4","method":"testCompleteException","assembly":"ApplicationInsights\\Tests\\Telemetry_Client_Test"},{"level":"3","method":"throwNestedException","assembly":"ApplicationInsights\\Tests\\Utils","fileName":"G:\\GitHub\\AppInsights-PHP\\ApplicationInsights\\Tests\\Telemetry_Client_Test.php","line":37},{"level":"2","method":"throwNestedException","assembly":"ApplicationInsights\\Tests\\Utils","fileName":"G:\\GitHub\\AppInsights-PHP\\ApplicationInsights\\Tests\\Utils.php","line":133},{"level":"1","method":"throwNestedException","assembly":"ApplicationInsights\\Tests\\Utils","fileName":"G:\\GitHub\\AppInsights-PHP\\ApplicationInsights\\Tests\\Utils.php","line":133},{"level":"0","method":"throwNestedException","assembly":"ApplicationInsights\\Tests\\Utils","fileName":"G:\\GitHub\\AppInsights-PHP\\ApplicationInsights\\Tests\\Utils.php","line":133}]}],"properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration_inner":42}},"baseType":"ExceptionData"}}]');
51
+ $expectedValue = json_decode($expectedString, true);
52
+
53
+ $this->assertEquals($this->removeMachineSpecificExceptionData($queue), $this->removeMachineSpecificExceptionData($expectedValue));
54
+
55
+ if (Utils::sendDataToServer())
56
+ {
57
+ $this->_telemetryClient->flush();
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Verifies the object is constructed properly.
63
+ */
64
+ public function testConstructor()
65
+ {
66
+ $telemetryClient = new \ApplicationInsights\Telemetry_Client();
67
+ $this->assertEquals($telemetryClient->getContext(), new \ApplicationInsights\Telemetry_Context());
68
+ $this->assertEquals($telemetryClient->getChannel(), new \ApplicationInsights\Channel\Telemetry_Channel());
69
+ }
70
+
71
+ /**
72
+ * Tests a completely filled event.
73
+ */
74
+ public function testCompleteEvent()
75
+ {
76
+ $this->_telemetryClient->trackEvent('myEvent', ['InlineProperty' => 'test_value'], ['duration' => 42.0]);
77
+ $this->_telemetryClient->trackEvent('myEvent2', ['InlineProperty' => 'test_value'], ['duration' => 42.0]);
78
+
79
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
80
+ $queue = $this->adjustDataInQueue($queue);
81
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.Event","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"' . Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"name":"myEvent","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration":42}},"baseType":"EventData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.Event","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"name":"myEvent2","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration":42}},"baseType":"EventData"}}]', true);
82
+
83
+ $this->assertEquals($queue, $expectedValue);
84
+
85
+ if (Utils::sendDataToServer())
86
+ {
87
+ $this->_telemetryClient->flush();
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Tests a completely filled page view.
93
+ */
94
+ public function testCompletePageView()
95
+ {
96
+ $this->_telemetryClient->trackPageView('myPageView', 'http://www.foo.com', 256, ['InlineProperty' => 'test_value'], ['duration' => 42.0]);
97
+ $this->_telemetryClient->trackPageView('myPageView2', 'http://www.foo.com', 256, ['InlineProperty' => 'test_value'], ['duration' => 42.0]);
98
+
99
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
100
+ $queue = $this->adjustDataInQueue($queue);
101
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.PageView","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"name":"myPageView","url":"http:\/\/www.foo.com","duration":256,"properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration":42}},"baseType":"PageViewData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.PageView","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"name":"myPageView2","url":"http:\/\/www.foo.com","duration":256,"properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration":42}},"baseType":"PageViewData"}}]', true);
102
+
103
+ $this->assertEquals($queue, $expectedValue);
104
+
105
+ if (Utils::sendDataToServer())
106
+ {
107
+ $this->_telemetryClient->flush();
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Tests a completely filled metric.
113
+ */
114
+ public function testCompleteMetric()
115
+ {
116
+ $this->_telemetryClient->trackMetric('myMetric', 42.0, \ApplicationInsights\Channel\Contracts\Data_Point_Type::Aggregation, 5, 0, 1, 0.2, ['InlineProperty' => 'test_value']);
117
+ $this->_telemetryClient->trackMetric('myMetric2', 42.0, \ApplicationInsights\Channel\Contracts\Data_Point_Type::Aggregation, 5, 0, 1, 0.2, ['InlineProperty' => 'test_value']);
118
+
119
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
120
+ $queue = $this->adjustDataInQueue($queue);
121
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"metrics":[{"name":"myMetric","kind":1,"value":42,"count":5,"max":1,"stdDev":0.2}],"properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"}},"baseType":"MetricData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"metrics":[{"name":"myMetric2","kind":1,"value":42,"count":5,"max":1,"stdDev":0.2}],"properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"}},"baseType":"MetricData"}}]', true);
122
+
123
+ $this->assertEquals($queue, $expectedValue);
124
+
125
+ if (Utils::sendDataToServer())
126
+ {
127
+ $this->_telemetryClient->flush();
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Tests a completely filled request.
133
+ */
134
+ public function testCompleteRequest()
135
+ {
136
+ $this->_telemetryClient->trackRequest('myRequest', 'http://foo.bar', time(), 3754, 200, true, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
137
+ $this->_telemetryClient->trackRequest('myRequest2', 'http://foo.bar', time(), 3754, 200, false, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
138
+
139
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
140
+ $queue = $this->adjustDataInQueue($queue);
141
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"id":"ID_PLACEHOLDER","startTime":"TIME_PLACEHOLDER","duration":"00:00:03.754","responseCode":200,"success":true,"name":"myRequest","url":"http:\/\/foo.bar","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration_inner":42}},"baseType":"RequestData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"id":"ID_PLACEHOLDER","startTime":"TIME_PLACEHOLDER","duration":"00:00:03.754","responseCode":200,"success":false,"name":"myRequest2","url":"http:\/\/foo.bar","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration_inner":42}},"baseType":"RequestData"}}]', true);
142
+
143
+ $this->assertEquals($queue, $expectedValue);
144
+
145
+ if (Utils::sendDataToServer())
146
+ {
147
+ $this->_telemetryClient->flush();
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Tests a completely filled request created by begin/end pair.
153
+ */
154
+ public function testCompleteBeginEndRequest()
155
+ {
156
+ $request = $this->_telemetryClient->beginRequest('myRequest', 'http://foo.bar', time());
157
+
158
+ // that shouldn't have queued anything so the queue should be empty
159
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
160
+ $this->assertEquals($queue, array());
161
+
162
+ // now queue that request, and another begin/end pair
163
+ $this->_telemetryClient->endRequest($request, 3754, 200, true, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
164
+
165
+ $request = $this->_telemetryClient->beginRequest('myRequest2', 'http://foo.bar', time());
166
+ $this->_telemetryClient->endRequest($request, 3754, 200, false, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
167
+
168
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
169
+ $queue = $this->adjustDataInQueue($queue);
170
+ // expected to look exactly the same as testCompleteRequest
171
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"id":"ID_PLACEHOLDER","startTime":"TIME_PLACEHOLDER","duration":"00:00:03.754","responseCode":200,"success":true,"name":"myRequest","url":"http:\/\/foo.bar","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration_inner":42}},"baseType":"RequestData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"id":"ID_PLACEHOLDER","startTime":"TIME_PLACEHOLDER","duration":"00:00:03.754","responseCode":200,"success":false,"name":"myRequest2","url":"http:\/\/foo.bar","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"},"measurements":{"duration_inner":42}},"baseType":"RequestData"}}]', true);
172
+
173
+ $this->assertEquals($queue, $expectedValue);
174
+
175
+ if (Utils::sendDataToServer())
176
+ {
177
+ $this->_telemetryClient->flush();
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Tests a completely filled message.
183
+ */
184
+ public function testCompleteMessage()
185
+ {
186
+ $this->_telemetryClient->trackMessage('myMessage', ['InlineProperty' => 'test_value']);
187
+ $this->_telemetryClient->trackMessage('myMessage2', ['InlineProperty' => 'test_value']);
188
+
189
+ $queue = json_decode($this->_telemetryClient->getChannel()->getSerializedQueue(), true);
190
+ $queue = $this->adjustDataInQueue($queue);
191
+ $expectedValue = json_decode('[{"ver":1,"name":"Microsoft.ApplicationInsights.Message","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"message":"myMessage","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"}},"baseType":"MessageData"}},{"ver":1,"name":"Microsoft.ApplicationInsights.Message","time":"TIME_PLACEHOLDER","sampleRate":100,"iKey":"'. Utils::getTestInstrumentationKey() . '","tags":{"ai.application.ver":"1.0.0.0","ai.device.id":"my_device_id","ai.device.ip":"127.0.0.1","ai.device.language":"EN","ai.device.locale":"EN","ai.device.model":"my_device_model","ai.device.network":5,"ai.device.oemName":"my_device_oem_name","ai.device.os":"Window","ai.device.osVersion":"8","ai.device.roleInstance":"device role instance","ai.device.roleName":"device role name","ai.device.screenResolution":"1920x1080","ai.device.type":"PC","ai.device.vmName":"device vm name","ai.location.ip":"127.0.0.0","ai.operation.id":"my_operation_id","ai.operation.name":"my_operation_name","ai.operation.parentId":"my_operation_parent_id","ai.operation.rootId":"my_operation_rood","ai.session.id":"my_session_id","ai.session.isFirst":"false","ai.session.isNew":"false","ai.user.id":"my_user_id","ai.user.accountAcquisitionDate":"1\/1\/2014","ai.user.accountId":"my_account_id","ai.user.userAgent":"my_user_agent","ai.internal.sdkVersion":"SDK_VERSION_STRING"},"data":{"baseData":{"ver":2,"message":"myMessage2","properties":{"InlineProperty":"test_value","MyCustomProperty":42,"MyCustomProperty2":"test"}},"baseType":"MessageData"}}]', true);
192
+
193
+ $this->assertEquals($queue, $expectedValue);
194
+
195
+ if (Utils::sendDataToServer())
196
+ {
197
+ $this->_telemetryClient->flush();
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Removes machine specific data from exceptions.
203
+ * @param array $queue The queue of items
204
+ * @return array
205
+ */
206
+ private function removeMachineSpecificExceptionData($queue)
207
+ {
208
+ foreach ($queue as &$queueItem)
209
+ {
210
+