PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.37
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.37
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
wpvr / vendor / posthog / posthog-php / test / MockedHttpClient.php

MockedHttpClient.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.37, at vendor/posthog/posthog-php/test/MockedHttpClient.php

58 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PostHog\Test;
4
5 use Closure;
6 use PostHog\HttpResponse;
7 use PostHog\Test\Assets\MockedResponses;
8
9 class MockedHttpClient extends \PostHog\HttpClient
10 {
11 public $calls;
12
13 private $flagEndpointResponse;
14 private $flagsEndpointResponse;
15
16 public function __construct(
17 string $host,
18 bool $useSsl = true,
19 int $maximumBackoffDuration = 10000,
20 bool $compressRequests = false,
21 bool $debug = false,
22 ?Closure $errorHandler = null,
23 int $curlTimeoutMilliseconds = 750,
24 array $flagEndpointResponse = [],
25 array $flagsEndpointResponse = []
26 ) {
27 parent::__construct(
28 $host,
29 $useSsl,
30 $maximumBackoffDuration,
31 $compressRequests,
32 $debug,
33 $errorHandler,
34 $curlTimeoutMilliseconds
35 );
36 $this->flagEndpointResponse = $flagEndpointResponse;
37 $this->flagsEndpointResponse = !empty($flagsEndpointResponse) ? $flagsEndpointResponse : MockedResponses::FLAGS_REQUEST;
38 }
39
40 public function sendRequest(string $path, ?string $payload, array $extraHeaders = [], array $requestOptions = []): HttpResponse
41 {
42 if (!isset($this->calls)) {
43 $this->calls = [];
44 }
45 array_push($this->calls, array("path" => $path, "payload" => $payload, "extraHeaders" => $extraHeaders, "requestOptions" => $requestOptions));
46
47 if (str_starts_with($path, "/flags/")) {
48 return new HttpResponse(json_encode($this->flagsEndpointResponse), 200);
49 }
50
51 if (str_starts_with($path, "/api/feature_flag/local_evaluation")) {
52 return new HttpResponse(json_encode($this->flagEndpointResponse), 200);
53 }
54
55 return parent::sendRequest($path, $payload, $extraHeaders, $requestOptions);
56 }
57 }
58