PrefixOption.php 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Configuration;
  11. use Predis\Command\Processor\KeyPrefixProcessor;
  12. use Predis\Command\Processor\CommandProcessorInterface;
  13. /**
  14. * Configures a command processor that apply the specified
  15. * prefix string to a series of Redis commands considered
  16. * prefixable.
  17. *
  18. * @author Daniele Alessandri <suppakilla@gmail.com>
  19. */
  20. class PrefixOption implements OptionInterface
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function filter(OptionsInterface $options, $value)
  26. {
  27. if ($value instanceof CommandProcessorInterface) {
  28. return $value;
  29. }
  30. return new KeyPrefixProcessor($value);
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function getDefault(OptionsInterface $options)
  36. {
  37. // NOOP
  38. }
  39. }