RedisFactory.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * Command factory for the mainline Redis server.
  13. *
  14. * @author Daniele Alessandri <suppakilla@gmail.com>
  15. */
  16. class RedisFactory extends Factory
  17. {
  18. /**
  19. *
  20. */
  21. public function __construct()
  22. {
  23. $this->commands = array(
  24. 'ECHO' => 'Predis\Command\Redis\ECHO_',
  25. 'EVAL' => 'Predis\Command\Redis\EVAL_',
  26. );
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getCommandClass($commandID)
  32. {
  33. $commandID = strtoupper($commandID);
  34. if (isset($this->commands[$commandID]) || array_key_exists($commandID, $this->commands)) {
  35. $commandClass = $this->commands[$commandID];
  36. } elseif (class_exists($commandClass = "Predis\Command\Redis\\$commandID")) {
  37. $this->commands[$commandID] = $commandClass;
  38. } else {
  39. return;
  40. }
  41. return $commandClass;
  42. }
  43. }