ScriptedCommand.php 658 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace Predis\Commands;
  3. abstract class ScriptedCommand extends ServerEval {
  4. public abstract function getScript();
  5. public abstract function keysCount();
  6. protected function filterArguments(Array $arguments) {
  7. if (($keys = $this->keysCount()) === -1) {
  8. $keys = count($arguments);
  9. }
  10. return array_merge(array($this->getScript(), $keys), $arguments);
  11. }
  12. protected function getKeys() {
  13. $arguments = $this->getArguments();
  14. if (($keys = $this->keysCount()) === -1) {
  15. return array_slice($arguments, 2);
  16. }
  17. return array_slice($arguments, 2, $keys);
  18. }
  19. }