File manager - Edit - /home/u816558632/domains/postills.com/public_html/public/graham-campbell.tar
Back
guzzle-factory/composer.json 0000644 00000002011 15002137243 0012242 0 ustar 00 { "name": "graham-campbell/guzzle-factory", "description": "Provides A Simple Guzzle Factory With Good Defaults", "keywords": ["guzzle", "http", "guzzle factory", "guzzle-factory", "Guzzle", "Guzzle Factory", "Guzzle-Factory", "Graham Campbell", "GrahamCampbell"], "license": "MIT", "authors": [ { "name": "Graham Campbell", "email": "hello@gjcampbell.co.uk", "homepage": "https://github.com/GrahamCampbell" } ], "require": { "php": "^7.4.15 || ^8.0.2", "guzzlehttp/guzzle": "^7.8.1", "guzzlehttp/psr7": "^2.6.2" }, "require-dev": { "graham-campbell/analyzer": "^4.1", "phpunit/phpunit": "^9.6.14 || ^10.5.1" }, "autoload": { "psr-4": { "GrahamCampbell\\GuzzleFactory\\": "src/" } }, "autoload-dev": { "psr-4": { "GrahamCampbell\\Tests\\GuzzleFactory\\": "tests/" } }, "config": { "preferred-install": "dist" } } guzzle-factory/LICENSE 0000644 00000002130 15002137243 0010527 0 ustar 00 The MIT License (MIT) Copyright (c) 2017-2023 Graham Campbell <hello@gjcampbell.co.uk> 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. guzzle-factory/src/GuzzleFactory.php 0000644 00000011121 15002137243 0013632 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of Guzzle Factory. * * (c) Graham Campbell <hello@gjcampbell.co.uk> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace GrahamCampbell\GuzzleFactory; use Closure; use GuzzleHttp\BodySummarizer; use GuzzleHttp\Client; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\TransferException; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\RequestOptions; use GuzzleHttp\RetryMiddleware; use GuzzleHttp\Utils; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** * This is the guzzle factory class. * * @author Graham Campbell <hello@gjcampbell.co.uk> */ final class GuzzleFactory { /** * The default crypto method. * * @var int */ private const CRYPTO_METHOD = \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; /** * The default connect timeout. * * @var int */ private const CONNECT_TIMEOUT = 10; /** * The default transport timeout. * * @var int */ private const TIMEOUT = 15; /** * The default backoff multiplier. * * @var int */ private const BACKOFF = 1000; /** * The default 4xx retry codes. * * @var int[] */ private const CODES = [429]; /** * The default amount of retries. */ private const RETRIES = 3; /** * Create a new guzzle client. * * @param array $options * @param int|null $backoff * @param int[]|null $codes * @param int|null $retries * * @return \GuzzleHttp\Client */ public static function make( array $options = [], int $backoff = null, array $codes = null, int $retries = null ): Client { $config = array_merge([ RequestOptions::CRYPTO_METHOD => self::CRYPTO_METHOD, RequestOptions::CONNECT_TIMEOUT => self::CONNECT_TIMEOUT, RequestOptions::TIMEOUT => self::TIMEOUT, ], $options); $config['handler'] = self::handler($backoff, $codes, $retries, $options['handler'] ?? null); return new Client($config); } /** * Create a new retrying handler stack. * * @param int|null $backoff * @param int[]|null $codes * @param int|null $retries * @param \GuzzleHttp\HandlerStack|null $stack * * @return \GuzzleHttp\HandlerStack */ public static function handler( int $backoff = null, array $codes = null, int $retries = null, HandlerStack $stack = null ): HandlerStack { $stack = $stack ?? self::innerHandler(); if ($retries === 0) { return $stack; } $stack->push(self::createRetryMiddleware($backoff ?? self::BACKOFF, $codes ?? self::CODES, $retries ?? self::RETRIES), 'retry'); return $stack; } /** * Create a new handler stack. * * @param callable|null $handler * * @return \GuzzleHttp\HandlerStack */ public static function innerHandler( callable $handler = null ): HandlerStack { $stack = new HandlerStack($handler ?? Utils::chooseHandler()); $stack->push(Middleware::httpErrors(new BodySummarizer(250)), 'http_errors'); $stack->push(Middleware::redirect(), 'allow_redirects'); $stack->push(Middleware::cookies(), 'cookies'); $stack->push(Middleware::prepareBody(), 'prepare_body'); return $stack; } /** * Create a new retry middleware. * * @param int $backoff * @param int[] $codes * @param int $maxRetries * * @return Closure */ private static function createRetryMiddleware( int $backoff, array $codes, int $maxRetries ): Closure { $decider = static function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) use ($codes, $maxRetries) { return $retries < $maxRetries && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || in_array($response->getStatusCode(), $codes, true)))); }; $delay = static function ($retries) use ($backoff) { return (int) pow(2, $retries) * $backoff; }; return static function (callable $handler) use ($decider, $delay): RetryMiddleware { return new RetryMiddleware($decider, $handler, $delay); }; } } result-type/composer.json 0000644 00000001607 15002137243 0011564 0 ustar 00 { "name": "graham-campbell/result-type", "description": "An Implementation Of The Result Type", "keywords": ["result", "result-type", "Result", "Result Type", "Result-Type", "Graham Campbell", "GrahamCampbell"], "license": "MIT", "authors": [ { "name": "Graham Campbell", "email": "hello@gjcampbell.co.uk", "homepage": "https://github.com/GrahamCampbell" } ], "require": { "php": "^7.2.5 || ^8.0", "phpoption/phpoption": "^1.9.2" }, "require-dev": { "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" }, "autoload": { "psr-4": { "GrahamCampbell\\ResultType\\": "src/" } }, "autoload-dev": { "psr-4": { "GrahamCampbell\\Tests\\ResultType\\": "tests/" } }, "config": { "preferred-install": "dist" } } result-type/LICENSE 0000644 00000002130 15002137243 0010037 0 ustar 00 The MIT License (MIT) Copyright (c) 2020-2023 Graham Campbell <hello@gjcampbell.co.uk> 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. result-type/src/Success.php 0000644 00000004225 15002137243 0011751 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of Result Type. * * (c) Graham Campbell <hello@gjcampbell.co.uk> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace GrahamCampbell\ResultType; use PhpOption\None; use PhpOption\Some; /** * @template T * @template E * * @extends \GrahamCampbell\ResultType\Result<T,E> */ final class Success extends Result { /** * @var T */ private $value; /** * Internal constructor for a success value. * * @param T $value * * @return void */ private function __construct($value) { $this->value = $value; } /** * Create a new error value. * * @template S * * @param S $value * * @return \GrahamCampbell\ResultType\Result<S,E> */ public static function create($value) { return new self($value); } /** * Get the success option value. * * @return \PhpOption\Option<T> */ public function success() { return Some::create($this->value); } /** * Map over the success value. * * @template S * * @param callable(T):S $f * * @return \GrahamCampbell\ResultType\Result<S,E> */ public function map(callable $f) { return self::create($f($this->value)); } /** * Flat map over the success value. * * @template S * @template F * * @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f * * @return \GrahamCampbell\ResultType\Result<S,F> */ public function flatMap(callable $f) { return $f($this->value); } /** * Get the error option value. * * @return \PhpOption\Option<E> */ public function error() { return None::create(); } /** * Map over the error value. * * @template F * * @param callable(E):F $f * * @return \GrahamCampbell\ResultType\Result<T,F> */ public function mapError(callable $f) { return self::create($this->value); } } result-type/src/Error.php 0000644 00000004327 15002137243 0011435 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of Result Type. * * (c) Graham Campbell <hello@gjcampbell.co.uk> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace GrahamCampbell\ResultType; use PhpOption\None; use PhpOption\Some; /** * @template T * @template E * * @extends \GrahamCampbell\ResultType\Result<T,E> */ final class Error extends Result { /** * @var E */ private $value; /** * Internal constructor for an error value. * * @param E $value * * @return void */ private function __construct($value) { $this->value = $value; } /** * Create a new error value. * * @template F * * @param F $value * * @return \GrahamCampbell\ResultType\Result<T,F> */ public static function create($value) { return new self($value); } /** * Get the success option value. * * @return \PhpOption\Option<T> */ public function success() { return None::create(); } /** * Map over the success value. * * @template S * * @param callable(T):S $f * * @return \GrahamCampbell\ResultType\Result<S,E> */ public function map(callable $f) { return self::create($this->value); } /** * Flat map over the success value. * * @template S * @template F * * @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f * * @return \GrahamCampbell\ResultType\Result<S,F> */ public function flatMap(callable $f) { /** @var \GrahamCampbell\ResultType\Result<S,F> */ return self::create($this->value); } /** * Get the error option value. * * @return \PhpOption\Option<E> */ public function error() { return Some::create($this->value); } /** * Map over the error value. * * @template F * * @param callable(E):F $f * * @return \GrahamCampbell\ResultType\Result<T,F> */ public function mapError(callable $f) { return self::create($f($this->value)); } } result-type/src/Result.php 0000644 00000002532 15002137243 0011616 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of Result Type. * * (c) Graham Campbell <hello@gjcampbell.co.uk> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace GrahamCampbell\ResultType; /** * @template T * @template E */ abstract class Result { /** * Get the success option value. * * @return \PhpOption\Option<T> */ abstract public function success(); /** * Map over the success value. * * @template S * * @param callable(T):S $f * * @return \GrahamCampbell\ResultType\Result<S,E> */ abstract public function map(callable $f); /** * Flat map over the success value. * * @template S * @template F * * @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f * * @return \GrahamCampbell\ResultType\Result<S,F> */ abstract public function flatMap(callable $f); /** * Get the error option value. * * @return \PhpOption\Option<E> */ abstract public function error(); /** * Map over the error value. * * @template F * * @param callable(E):F $f * * @return \GrahamCampbell\ResultType\Result<T,F> */ abstract public function mapError(callable $f); }
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0 |
proxy
|
phpinfo
|
Settings