| Total Complexity | 11 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | class GuzzleFactory implements FactoryInterface |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Check whether Guzzle Http is available |
||
| 24 | */ |
||
| 25 | public static function isInstalled(): bool |
||
| 26 | { |
||
| 27 | return class_exists('GuzzleHttp\\Psr7\\Response') |
||
| 28 | && class_exists('GuzzleHttp\\Psr7\\ServerRequest') |
||
| 29 | && class_exists('GuzzleHttp\\Psr7\\Stream') |
||
| 30 | && class_exists('GuzzleHttp\\Psr7\\Uri'); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @inheritdoc |
||
| 35 | */ |
||
| 36 | public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @inheritdoc |
||
| 43 | */ |
||
| 44 | public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface |
||
| 45 | { |
||
| 46 | return new ServerRequest($method, $uri, [], null, '1.1', $serverParams); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @inheritdoc |
||
| 51 | */ |
||
| 52 | public function createStream(string $content = ''): StreamInterface |
||
| 53 | { |
||
| 54 | $stream = $this->createStreamFromFile('php://temp', 'r+'); |
||
| 55 | $stream->write($content); |
||
| 56 | |||
| 57 | return $stream; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @inheritdoc |
||
| 62 | */ |
||
| 63 | public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
||
| 64 | { |
||
| 65 | return $this->createStreamFromResource(fopen($filename, $mode)); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @inheritdoc |
||
| 70 | */ |
||
| 71 | public function createStreamFromResource($resource): StreamInterface |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @inheritdoc |
||
| 78 | */ |
||
| 79 | public function createUri(string $uri = ''): UriInterface |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @inheritdoc |
||
| 86 | */ |
||
| 87 | public function createUploadedFile( |
||
| 95 | } |
||
| 96 | } |
||
| 97 |