PrefixableCommand.php 737 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Command;
  11. /**
  12. * Base class for Redis commands with prefixable keys.
  13. *
  14. * @author Daniele Alessandri <suppakilla@gmail.com>
  15. */
  16. abstract class PrefixableCommand extends AbstractCommand implements PrefixableCommandInterface
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function prefixKeys($prefix)
  22. {
  23. if ($arguments = $this->getArguments()) {
  24. $arguments[0] = "$prefix{$arguments[0]}";
  25. $this->setRawArguments($arguments);
  26. }
  27. }
  28. }