PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / vendor / guzzlehttp / psr7 / src / HttpFactory.php

HttpFactory.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/guzzlehttp/psr7/src/HttpFactory.php

95 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace GuzzleHttp\Psr7;
6
7 use Psr\Http\Message\RequestFactoryInterface;
8 use Psr\Http\Message\RequestInterface;
9 use Psr\Http\Message\ResponseFactoryInterface;
10 use Psr\Http\Message\ResponseInterface;
11 use Psr\Http\Message\ServerRequestFactoryInterface;
12 use Psr\Http\Message\ServerRequestInterface;
13 use Psr\Http\Message\StreamFactoryInterface;
14 use Psr\Http\Message\StreamInterface;
15 use Psr\Http\Message\UploadedFileFactoryInterface;
16 use Psr\Http\Message\UploadedFileInterface;
17 use Psr\Http\Message\UriFactoryInterface;
18 use Psr\Http\Message\UriInterface;
19
20 /**
21 * Implements all of the PSR-17 interfaces.
22 *
23 * Note: in consuming code it is recommended to require the implemented interfaces
24 * and inject the instance of this class multiple times.
25 */
26 final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
27 {
28 public function createUploadedFile(
29 StreamInterface $stream,
30 ?int $size = null,
31 int $error = \UPLOAD_ERR_OK,
32 ?string $clientFilename = null,
33 ?string $clientMediaType = null
34 ): UploadedFileInterface {
35 if ($size === null) {
36 $size = $stream->getSize();
37 }
38
39 return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
40 }
41
42 public function createStream(string $content = ''): StreamInterface
43 {
44 return Utils::streamFor($content);
45 }
46
47 public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
48 {
49 try {
50 $resource = Utils::tryFopen($file, $mode);
51 } catch (\RuntimeException $e) {
52 if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) {
53 throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e);
54 }
55
56 throw $e;
57 }
58
59 return Utils::streamFor($resource);
60 }
61
62 public function createStreamFromResource($resource): StreamInterface
63 {
64 return Utils::streamFor($resource);
65 }
66
67 public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
68 {
69 if (empty($method)) {
70 if (!empty($serverParams['REQUEST_METHOD'])) {
71 $method = $serverParams['REQUEST_METHOD'];
72 } else {
73 throw new \InvalidArgumentException('Cannot determine HTTP method');
74 }
75 }
76
77 return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
78 }
79
80 public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
81 {
82 return new Response($code, [], null, '1.1', $reasonPhrase);
83 }
84
85 public function createRequest(string $method, $uri): RequestInterface
86 {
87 return new Request($method, $uri);
88 }
89
90 public function createUri(string $uri = ''): UriInterface
91 {
92 return new Uri($uri);
93 }
94 }
95