mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 23:47:03 +03:00
Predis to v2.2.2
This commit is contained in:
parent
9510347d3a
commit
969dca5f7e
449 changed files with 22013 additions and 2 deletions
40
plugins/cache-redis/Predis/Command/Traits/By/ByArgument.php
Normal file
40
plugins/cache-redis/Predis/Command/Traits/By/ByArgument.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Traits\By;
|
||||
|
||||
use Predis\Command\Command;
|
||||
|
||||
/**
|
||||
* @mixin Command
|
||||
*/
|
||||
trait ByArgument
|
||||
{
|
||||
private $byModifier = 'BY';
|
||||
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
$argumentsLength = count($arguments);
|
||||
|
||||
if (static::$byArgumentPositionOffset >= $argumentsLength || null === $arguments[static::$byArgumentPositionOffset]) {
|
||||
parent::setArguments($arguments);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$argument = $arguments[static::$byArgumentPositionOffset];
|
||||
$argumentsBefore = array_slice($arguments, 0, static::$byArgumentPositionOffset);
|
||||
$argumentsAfter = array_slice($arguments, static::$byArgumentPositionOffset + 1);
|
||||
|
||||
parent::setArguments(array_merge($argumentsBefore, [$this->byModifier, $argument], $argumentsAfter));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Traits\By;
|
||||
|
||||
use Predis\Command\Command;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @mixin Command
|
||||
*/
|
||||
trait ByLexByScore
|
||||
{
|
||||
private static $argumentsEnum = [
|
||||
'bylex' => 'BYLEX',
|
||||
'byscore' => 'BYSCORE',
|
||||
];
|
||||
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
$argument = $arguments[static::$byLexByScoreArgumentPositionOffset];
|
||||
|
||||
if (false === $argument) {
|
||||
parent::setArguments($arguments);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_string($argument) && in_array(strtoupper($argument), self::$argumentsEnum)) {
|
||||
$argument = self::$argumentsEnum[$argument];
|
||||
} else {
|
||||
throw new UnexpectedValueException('By argument accepts only "bylex" and "byscore" values');
|
||||
}
|
||||
|
||||
$argumentsBefore = array_slice($arguments, 0, static::$byLexByScoreArgumentPositionOffset);
|
||||
$argumentsAfter = array_slice($arguments, static::$byLexByScoreArgumentPositionOffset + 1);
|
||||
|
||||
parent::setArguments(array_merge($argumentsBefore, [$argument], $argumentsAfter));
|
||||
}
|
||||
}
|
||||
49
plugins/cache-redis/Predis/Command/Traits/By/GeoBy.php
Normal file
49
plugins/cache-redis/Predis/Command/Traits/By/GeoBy.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Traits\By;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Predis\Command\Argument\Geospatial\ByInterface;
|
||||
|
||||
trait GeoBy
|
||||
{
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
$argumentPositionOffset = $this->getByArgumentPositionOffset($arguments);
|
||||
|
||||
if (null === $argumentPositionOffset) {
|
||||
throw new InvalidArgumentException('Invalid BY argument value given');
|
||||
}
|
||||
|
||||
$byArgumentObject = $arguments[$argumentPositionOffset];
|
||||
$argumentsBefore = array_slice($arguments, 0, $argumentPositionOffset);
|
||||
$argumentsAfter = array_slice($arguments, $argumentPositionOffset + 1);
|
||||
|
||||
parent::setArguments(array_merge(
|
||||
$argumentsBefore,
|
||||
$byArgumentObject->toArray(),
|
||||
$argumentsAfter
|
||||
));
|
||||
}
|
||||
|
||||
private function getByArgumentPositionOffset(array $arguments): ?int
|
||||
{
|
||||
foreach ($arguments as $i => $value) {
|
||||
if ($value instanceof ByInterface) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue