PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.19
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.19
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / guzzlehttp / psr7 / src / HttpFactory.php

HttpFactory.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.19, at vendor_prefixed/guzzlehttp/psr7/src/HttpFactory.php

77 lines 3.2 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 namespace WCPOS\Vendor\GuzzleHttp\Psr7;
5
6 use WCPOS\Vendor\Psr\Http\Message\RequestFactoryInterface;
7 use WCPOS\Vendor\Psr\Http\Message\RequestInterface;
8 use WCPOS\Vendor\Psr\Http\Message\ResponseFactoryInterface;
9 use WCPOS\Vendor\Psr\Http\Message\ResponseInterface;
10 use WCPOS\Vendor\Psr\Http\Message\ServerRequestFactoryInterface;
11 use WCPOS\Vendor\Psr\Http\Message\ServerRequestInterface;
12 use WCPOS\Vendor\Psr\Http\Message\StreamFactoryInterface;
13 use WCPOS\Vendor\Psr\Http\Message\StreamInterface;
14 use WCPOS\Vendor\Psr\Http\Message\UploadedFileFactoryInterface;
15 use WCPOS\Vendor\Psr\Http\Message\UploadedFileInterface;
16 use WCPOS\Vendor\Psr\Http\Message\UriFactoryInterface;
17 use WCPOS\Vendor\Psr\Http\Message\UriInterface;
18 /**
19 * Implements all of the PSR-17 interfaces.
20 *
21 * Note: in consuming code it is recommended to require the implemented interfaces
22 * and inject the instance of this class multiple times.
23 */
24 final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
25 {
26 public function createUploadedFile(StreamInterface $stream, ?int $size = null, int $error = \UPLOAD_ERR_OK, ?string $clientFilename = null, ?string $clientMediaType = null) : UploadedFileInterface
27 {
28 if ($size === null) {
29 $size = $stream->getSize();
30 }
31 return new UploadedFile($stream, Integers::assertOptionalNonNegativeSize($size, 'Uploaded file size'), $error, $clientFilename, $clientMediaType);
32 }
33 public function createStream(string $content = '') : StreamInterface
34 {
35 return Utils::streamFor($content);
36 }
37 public function createStreamFromFile(string $file, string $mode = 'r') : StreamInterface
38 {
39 try {
40 $resource = Utils::tryFopen($file, $mode);
41 } catch (\RuntimeException $e) {
42 if ('' === $mode || \false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], \true)) {
43 throw new \InvalidArgumentException(\sprintf('Invalid file opening mode: %s', DiagnosticValue::escape($mode)), 0, $e);
44 }
45 throw $e;
46 }
47 return Utils::streamFor($resource);
48 }
49 public function createStreamFromResource($resource) : StreamInterface
50 {
51 return Utils::streamFor($resource);
52 }
53 public function createServerRequest(string $method, $uri, #[\SensitiveParameter] array $serverParams = []) : ServerRequestInterface
54 {
55 if (empty($method)) {
56 if (!empty($serverParams['REQUEST_METHOD'])) {
57 $method = $serverParams['REQUEST_METHOD'];
58 } else {
59 throw new \InvalidArgumentException('Cannot determine HTTP method');
60 }
61 }
62 return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
63 }
64 public function createResponse(int $code = 200, string $reasonPhrase = '') : ResponseInterface
65 {
66 return new Response($code, [], null, '1.1', $reasonPhrase);
67 }
68 public function createRequest(string $method, $uri) : RequestInterface
69 {
70 return new Request($method, $uri);
71 }
72 public function createUri(string $uri = '') : UriInterface
73 {
74 return new Uri($uri);
75 }
76 }
77