Initial import

This commit is contained in:
Nextcloud Team 2021-11-30 11:20:42 +01:00 committed by Lukas Reschke
commit 2295a33590
884 changed files with 93939 additions and 0 deletions

View file

@ -0,0 +1,60 @@
name: CI
on:
pull_request:
push:
branches: [ master ]
jobs:
run:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php:
- '7.3'
- '7.4'
- '8.0'
minimum_versions: [false]
coverage: ['none']
include:
- description: 'Minimum version'
php: '7.3'
minimum_versions: true
- description: 'Log Code Coverage'
php: '8.0'
coverage: 'xdebug'
name: PHP ${{ matrix.php }} ${{ matrix.description }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: ${{ matrix.php }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage }}
- name: Install dependencies
run: composer install
if: matrix.minimum_versions == false
- name: Install dependencies (lowest versions)
run: composer update --no-interaction --prefer-lowest
if: matrix.minimum_versions == true
- name: Run PHPUnit tests
run: vendor/bin/phpunit
- name: Upload code coverage
uses: codecov/codecov-action@v2
if: matrix.coverage == 'xdebug'
with:
file: './build/logs/clover.xml'
fail_ci_if_error: true

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Woody Gilk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,7 @@
# HTTP Factory for Guzzle
HTTP factory implemented for [Guzzle](https://github.com/guzzle/psr7).
**NOTE:** `guzzlehttp/psr7` includes an HTTP factory implementation starting with
version 2.0. Please use the official factory if your project can use
`"guzzlehttp/psr7": "^2.0"`.

View file

@ -0,0 +1,37 @@
{
"name": "http-interop/http-factory-guzzle",
"description": "An HTTP Factory using Guzzle PSR7",
"keywords": [
"psr-7",
"psr-17",
"http",
"factory"
],
"license": "MIT",
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"provide": {
"psr/http-factory-implementation": "^1.0"
},
"require": {
"php": ">=7.3",
"psr/http-factory": "^1.0",
"guzzlehttp/psr7": "^1.7||^2.0"
},
"require-dev": {
"http-interop/http-factory-tests": "^0.9",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Http\\Factory\\Guzzle\\": "src/"
}
},
"suggest": {
"guzzlehttp/psr7": "Includes an HTTP factory starting in version 2.0"
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\Request;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
class RequestFactory implements RequestFactoryInterface
{
public function createRequest(string $method, $uri): RequestInterface
{
return new Request($method, $uri);
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
class ResponseFactory implements ResponseFactoryInterface
{
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
{
return new Response($code, [], null, '1.1', $reasonPhrase);
}
}

View file

@ -0,0 +1,24 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\ServerRequest;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
class ServerRequestFactory implements ServerRequestFactoryInterface
{
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
{
if (empty($method)) {
if (!empty($serverParams['REQUEST_METHOD'])) {
$method = $serverParams['REQUEST_METHOD'];
} else {
throw new \InvalidArgumentException('Cannot determine HTTP method');
}
}
return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\Stream;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
class StreamFactory implements StreamFactoryInterface
{
public function createStream(string $content = ''): StreamInterface
{
return Utils::streamFor($content);
}
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
{
return $this->createStreamFromResource(Utils::tryFopen($file, $mode));
}
public function createStreamFromResource($resource): StreamInterface
{
return new Stream($resource);
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\UploadedFile;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
class UploadedFileFactory implements UploadedFileFactoryInterface
{
public function createUploadedFile(
StreamInterface $stream,
int $size = null,
int $error = \UPLOAD_ERR_OK,
string $clientFilename = null,
string $clientMediaType = null
): UploadedFileInterface {
if ($size === null) {
$size = $stream->getSize();
}
return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace Http\Factory\Guzzle;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
class UriFactory implements UriFactoryInterface
{
public function createUri(string $uri = ''): UriInterface
{
return new Uri($uri);
}
}