Permalink
Browse files

Make it possible to cast key prefix processor instance to string.

Mostly useful with string interpolation when getting the current prefix
associated to a client instance.
  • Loading branch information...
1 parent 9901233 commit 83720075f3ac285153ed82ef1fcaf1170fb8b383 @nrk committed Dec 27, 2012
View
@@ -6,6 +6,9 @@ v0.8.1 (201x-xx-xx)
- Client options accepting callable objects as factories now pass their actual
instance to the callable as the second argument.
+- `Predis\Command\Processor\KeyPrefixProcessor` can now be directly casted to
+ string to obtain the current prefix, useful with string interpolation.
+
- __FIX__: a missing use directive in `Predis\Transaction\MultiExecContext`
caused PHP errors when Redis did not return `+QUEUED` replies to commands
when inside a MULTI / EXEC context.
@@ -61,4 +61,12 @@ public function process(CommandInterface $command)
$command->prefixKeys($this->prefix);
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function __toString()
+ {
+ return $this->getPrefix();
+ }
}
@@ -80,4 +80,15 @@ public function testProcessNotPrefixableCommands()
$processor->process($command);
}
+
+ /**
+ * @group disconnected
+ */
+ public function testInstanceCanBeCastedToString()
+ {
+ $prefix = 'prefix:';
+ $processor = new KeyPrefixProcessor($prefix);
+
+ $this->assertEquals($prefix, (string) $processor);
+ }
}

0 comments on commit 8372007

Please sign in to comment.