[COMPOSER] Added predis/predis and updated packages

This commit is contained in:
Miguel Dantas
2019-08-13 01:31:05 +01:00
committed by Diogo Peralta Cordeiro
parent 50c98d53c9
commit 19d68c9f8e
641 changed files with 58448 additions and 83 deletions

356
vendor/enqueue/dsn/Dsn.php vendored Normal file
View File

@@ -0,0 +1,356 @@
<?php
declare(strict_types=1);
namespace Enqueue\Dsn;
class Dsn
{
/**
* @var string
*/
private $scheme;
/**
* @var string
*/
private $schemeProtocol;
/**
* @var string[]
*/
private $schemeExtensions;
/**
* @var string|null
*/
private $user;
/**
* @var string|null
*/
private $password;
/**
* @var string|null
*/
private $host;
/**
* @var int|null
*/
private $port;
/**
* @var string|null
*/
private $path;
/**
* @var string|null
*/
private $queryString;
/**
* @var QueryBag
*/
private $queryBag;
public function __construct(
string $scheme,
string $schemeProtocol,
array $schemeExtensions,
?string $user,
?string $password,
?string $host,
?int $port,
?string $path,
?string $queryString,
array $query
) {
$this->scheme = $scheme;
$this->schemeProtocol = $schemeProtocol;
$this->schemeExtensions = $schemeExtensions;
$this->user = $user;
$this->password = $password;
$this->host = $host;
$this->port = $port;
$this->path = $path;
$this->queryString = $queryString;
$this->queryBag = new QueryBag($query);
}
public function getScheme(): string
{
return $this->scheme;
}
public function getSchemeProtocol(): string
{
return $this->schemeProtocol;
}
public function getSchemeExtensions(): array
{
return $this->schemeExtensions;
}
public function hasSchemeExtension(string $extension): bool
{
return in_array($extension, $this->schemeExtensions, true);
}
public function getUser(): ?string
{
return $this->user;
}
public function getPassword(): ?string
{
return $this->password;
}
public function getHost(): ?string
{
return $this->host;
}
public function getPort(): ?int
{
return $this->port;
}
public function getPath(): ?string
{
return $this->path;
}
public function getQueryString(): ?string
{
return $this->queryString;
}
public function getQueryBag(): QueryBag
{
return $this->queryBag;
}
public function getQuery(): array
{
return $this->queryBag->toArray();
}
public function getString(string $name, string $default = null): ?string
{
return $this->queryBag->getString($name, $default);
}
public function getDecimal(string $name, int $default = null): ?int
{
return $this->queryBag->getDecimal($name, $default);
}
public function getOctal(string $name, int $default = null): ?int
{
return $this->queryBag->getOctal($name, $default);
}
public function getFloat(string $name, float $default = null): ?float
{
return $this->queryBag->getFloat($name, $default);
}
public function getBool(string $name, bool $default = null): ?bool
{
return $this->queryBag->getBool($name, $default);
}
public function getArray(string $name, array $default = []): QueryBag
{
return $this->queryBag->getArray($name, $default);
}
public function toArray()
{
return [
'scheme' => $this->scheme,
'schemeProtocol' => $this->schemeProtocol,
'schemeExtensions' => $this->schemeExtensions,
'user' => $this->user,
'password' => $this->password,
'host' => $this->host,
'port' => $this->port,
'path' => $this->path,
'queryString' => $this->queryString,
'query' => $this->queryBag->toArray(),
];
}
public static function parseFirst(string $dsn): ?self
{
return self::parse($dsn)[0];
}
/**
* @param string $dsn
*
* @return Dsn[]
*/
public static function parse(string $dsn): array
{
if (false === strpos($dsn, ':')) {
throw new \LogicException(sprintf('The DSN is invalid. It does not have scheme separator ":".'));
}
list($scheme, $dsnWithoutScheme) = explode(':', $dsn, 2);
$scheme = strtolower($scheme);
if (false == preg_match('/^[a-z\d+-.]*$/', $scheme)) {
throw new \LogicException('The DSN is invalid. Scheme contains illegal symbols.');
}
$schemeParts = explode('+', $scheme);
$schemeProtocol = $schemeParts[0];
unset($schemeParts[0]);
$schemeExtensions = array_values($schemeParts);
$user = parse_url($dsn, PHP_URL_USER) ?: null;
if (is_string($user)) {
$user = rawurldecode($user);
}
$password = parse_url($dsn, PHP_URL_PASS) ?: null;
if (is_string($password)) {
$password = rawurldecode($password);
}
$path = parse_url($dsn, PHP_URL_PATH) ?: null;
if ($path) {
$path = rawurldecode($path);
}
$query = [];
$queryString = parse_url($dsn, PHP_URL_QUERY) ?: null;
if (is_string($queryString)) {
$query = self::httpParseQuery($queryString, '&', PHP_QUERY_RFC3986);
}
$hostsPorts = '';
if (0 === strpos($dsnWithoutScheme, '//')) {
$dsnWithoutScheme = substr($dsnWithoutScheme, 2);
$dsnWithoutUserPassword = explode('@', $dsnWithoutScheme, 2);
$dsnWithoutUserPassword = 2 === count($dsnWithoutUserPassword) ?
$dsnWithoutUserPassword[1] :
$dsnWithoutUserPassword[0]
;
list($hostsPorts) = explode('#', $dsnWithoutUserPassword, 2);
list($hostsPorts) = explode('?', $hostsPorts, 2);
list($hostsPorts) = explode('/', $hostsPorts, 2);
}
if (empty($hostsPorts)) {
return [
new self(
$scheme,
$schemeProtocol,
$schemeExtensions,
null,
null,
null,
null,
$path,
$queryString,
$query
),
];
}
$dsns = [];
$hostParts = explode(',', $hostsPorts);
foreach ($hostParts as $key => $hostPart) {
unset($hostParts[$key]);
$parts = explode(':', $hostPart, 2);
$host = $parts[0];
$port = null;
if (isset($parts[1])) {
$port = (int) $parts[1];
}
$dsns[] = new self(
$scheme,
$schemeProtocol,
$schemeExtensions,
$user,
$password,
$host,
$port,
$path,
$queryString,
$query
);
}
return $dsns;
}
/**
* based on http://php.net/manual/en/function.parse-str.php#119484 with some slight modifications.
*/
private static function httpParseQuery(string $queryString, string $argSeparator = '&', int $decType = PHP_QUERY_RFC1738): array
{
$result = [];
$parts = explode($argSeparator, $queryString);
foreach ($parts as $part) {
list($paramName, $paramValue) = explode('=', $part, 2);
switch ($decType) {
case PHP_QUERY_RFC3986:
$paramName = rawurldecode($paramName);
$paramValue = rawurldecode($paramValue);
break;
case PHP_QUERY_RFC1738:
default:
$paramName = urldecode($paramName);
$paramValue = urldecode($paramValue);
break;
}
if (preg_match_all('/\[([^\]]*)\]/m', $paramName, $matches)) {
$paramName = substr($paramName, 0, strpos($paramName, '['));
$keys = array_merge([$paramName], $matches[1]);
} else {
$keys = [$paramName];
}
$target = &$result;
foreach ($keys as $index) {
if ('' === $index) {
if (is_array($target)) {
$intKeys = array_filter(array_keys($target), 'is_int');
$index = count($intKeys) ? max($intKeys) + 1 : 0;
} else {
$target = [$target];
$index = 1;
}
} elseif (isset($target[$index]) && !is_array($target[$index])) {
$target[$index] = [$target[$index]];
}
$target = &$target[$index];
}
if (is_array($target)) {
$target[] = $paramValue;
} else {
$target = $paramValue;
}
}
return $result;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Enqueue\Dsn;
final class InvalidQueryParameterTypeException extends \LogicException
{
public static function create(string $name, string $expectedType): self
{
return new static(sprintf('The query parameter "%s" has invalid type. It must be "%s"', $name, $expectedType));
}
}

20
vendor/enqueue/dsn/LICENSE vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2018 Kotliar Maksym
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.

103
vendor/enqueue/dsn/QueryBag.php vendored Normal file
View File

@@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
namespace Enqueue\Dsn;
class QueryBag
{
/**
* @var array
*/
private $query;
public function __construct(array $query)
{
$this->query = $query;
}
public function toArray(): array
{
return $this->query;
}
public function getString(string $name, string $default = null): ?string
{
return array_key_exists($name, $this->query) ? $this->query[$name] : $default;
}
public function getDecimal(string $name, int $default = null): ?int
{
$value = $this->getString($name);
if (null === $value) {
return $default;
}
if (false == preg_match('/^[\+\-]?[0-9]*$/', $value)) {
throw InvalidQueryParameterTypeException::create($name, 'decimal');
}
return (int) $value;
}
public function getOctal(string $name, int $default = null): ?int
{
$value = $this->getString($name);
if (null === $value) {
return $default;
}
if (false == preg_match('/^0[\+\-]?[0-7]*$/', $value)) {
throw InvalidQueryParameterTypeException::create($name, 'octal');
}
return intval($value, 8);
}
public function getFloat(string $name, float $default = null): ?float
{
$value = $this->getString($name);
if (null === $value) {
return $default;
}
if (false == is_numeric($value)) {
throw InvalidQueryParameterTypeException::create($name, 'float');
}
return (float) $value;
}
public function getBool(string $name, bool $default = null): ?bool
{
$value = $this->getString($name);
if (null === $value) {
return $default;
}
if (in_array($value, ['', '0', 'false'], true)) {
return false;
}
if (in_array($value, ['1', 'true'], true)) {
return true;
}
throw InvalidQueryParameterTypeException::create($name, 'bool');
}
public function getArray(string $name, array $default = []): self
{
if (false == array_key_exists($name, $this->query)) {
return new self($default);
}
$value = $this->query[$name];
if (is_array($value)) {
return new self($value);
}
throw InvalidQueryParameterTypeException::create($name, 'array');
}
}

29
vendor/enqueue/dsn/README.md vendored Normal file
View File

@@ -0,0 +1,29 @@
<h2 align="center">Supporting Enqueue</h2>
Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:
- [Become a sponsor](https://www.patreon.com/makasim)
- [Become our client](http://forma-pro.com/)
---
# Enqueue. Parse DSN class
## Resources
* [Site](https://enqueue.forma-pro.com/)
* [Documentation](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/dsn.md)
* [Questions](https://gitter.im/php-enqueue/Lobby)
* [Issue Tracker](https://github.com/php-enqueue/enqueue-dev/issues)
## Developed by Forma-Pro
Forma-Pro is a full stack development company which interests also spread to open source development.
Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience.
Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.
If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com
## License
It is released under the [MIT License](LICENSE).

33
vendor/enqueue/dsn/composer.json vendored Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "enqueue/dsn",
"type": "library",
"description": "Parse DSN",
"keywords": ["dsn", "parse"],
"homepage": "https://enqueue.forma-pro.com/",
"license": "MIT",
"require": {
"php": "^7.1.3"
},
"require-dev": {
"phpunit/phpunit": "~5.4.0"
},
"support": {
"email": "opensource@forma-pro.com",
"issues": "https://github.com/php-enqueue/enqueue-dev/issues",
"forum": "https://gitter.im/php-enqueue/Lobby",
"source": "https://github.com/php-enqueue/enqueue-dev",
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"autoload": {
"psr-4": { "Enqueue\\Dsn\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "0.9.x-dev"
}
}
}