Skip to content

Commit 4383b46

Browse files
committed
Use constant instead of hardcoded version
1 parent c51d0d1 commit 4383b46

30 files changed

+36
-32
lines changed

src/Index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use function count;
2525
use function is_array;
2626
use function is_string;
27+
use MacFJA\RediSearch\Redis\Command\AbstractCommand;
2728
use MacFJA\RediSearch\Redis\Command\AliasAdd;
2829
use MacFJA\RediSearch\Redis\Command\AliasDel;
2930
use MacFJA\RediSearch\Redis\Command\AliasUpdate;
@@ -54,7 +55,7 @@ public function __construct(string $index, ClientInterface $client)
5455
{
5556
$this->client = $client;
5657
$this->index = $index;
57-
$this->version = Initializer::getRediSearchVersion($client) ?? '2.0.0';
58+
$this->version = Initializer::getRediSearchVersion($client) ?? AbstractCommand::MIN_IMPLEMENTED_VERSION;
5859
$this->getInfo();
5960
}
6061

src/IndexBuilder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use function is_float;
3030
use function is_int;
3131
use function is_string;
32+
use MacFJA\RediSearch\Redis\Command\AbstractCommand;
3233
use MacFJA\RediSearch\Redis\Command\AddFieldOptionTrait;
3334
use MacFJA\RediSearch\Redis\Command\Create;
3435
use MacFJA\RediSearch\Redis\Command\CreateCommand\CreateCommandFieldOption;
@@ -167,7 +168,7 @@ public function addField(CreateCommandFieldOption ...$option): self
167168
return $this;
168169
}
169170

170-
public function create(ClientInterface $client, string $rediSearchVersion = '2.0.0'): ResponseInterface
171+
public function create(ClientInterface $client, string $rediSearchVersion = AbstractCommand::MIN_IMPLEMENTED_VERSION): ResponseInterface
171172
{
172173
$command = $this->getCommand($rediSearchVersion);
173174

@@ -180,7 +181,7 @@ public function create(ClientInterface $client, string $rediSearchVersion = '2.0
180181
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
181182
* @SuppressWarnings(PHPMD.NPathComplexity)
182183
*/
183-
public function getCommand(string $rediSearchVersion = '2.0.0'): Create
184+
public function getCommand(string $rediSearchVersion = AbstractCommand::MIN_IMPLEMENTED_VERSION): Create
184185
{
185186
if (!is_string($this->index)) {
186187
throw new RuntimeException('The index name is missing');

src/Redis/Command/AbstractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class AbstractCommand extends Command
4646
/**
4747
* @param array<array<CommandOption>|CommandOption|mixed> $options
4848
*/
49-
public function __construct(array $options, string $rediSearchVersion = '2.0.0')
49+
public function __construct(array $options, string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
5050
{
5151
$this->rediSearchVersion = $rediSearchVersion;
5252

src/Redis/Command/Aggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Aggregate extends AbstractCommand implements PaginatedCommand
4343
{
4444
use ArrayResponseTrait;
4545

46-
public function __construct(string $rediSearchVersion = '2.0.0')
46+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
4747
{
4848
parent::__construct([
4949
'index' => new NamelessOption(null, '>=2.0.0'),

src/Redis/Command/AliasAdd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
class AliasAdd extends AbstractCommand
3131
{
32-
public function __construct(string $rediSearchVersion = '2.0.0')
32+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3333
{
3434
parent::__construct([
3535
'alias' => new NamelessOption(null, '>=2.0.0'),

src/Redis/Command/AliasDel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
class AliasDel extends AbstractCommand
3131
{
32-
public function __construct(string $rediSearchVersion = '2.0.0')
32+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3333
{
3434
parent::__construct([
3535
'alias' => new NamelessOption(null, '>=2.0.0'),

src/Redis/Command/AliasUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
class AliasUpdate extends AbstractCommand
3131
{
32-
public function __construct(string $rediSearchVersion = '2.0.0')
32+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3333
{
3434
parent::__construct([
3535
'alias' => new NamelessOption(null, '>=2.0.0'),

src/Redis/Command/Alter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Alter extends AbstractCommand
3232
{
3333
use AddFieldOptionTrait;
3434

35-
public function __construct(string $rediSearchVersion = '2.0.0')
35+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3636
{
3737
parent::__construct([
3838
'index' => new NamelessOption(null, '>=2.0.0'),

src/Redis/Command/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
class Config extends AbstractCommand
3131
{
32-
public function __construct(string $rediSearchVersion = '2.0.0')
32+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3333
{
3434
parent::__construct([
3535
'action' => CustomValidatorOption::allowedValues(new NamelessOption(null, '>=2.0.0'), ['GET', 'HELP']),

src/Redis/Command/ConfigSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
class ConfigSet extends AbstractCommand
3333
{
34-
public function __construct(string $rediSearchVersion = '2.0.0')
34+
public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VERSION)
3535
{
3636
parent::__construct([
3737
'action' => new FlagOption('SET', true, '>=2.0.0'),

0 commit comments

Comments
 (0)