PrefixOption.php 988 B

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