Debian Codegraph @

vendor/clue/redis-protocol/src/Clue/Redis/Protocol/Model/Request.php

raw
1 <?php
2
3 namespace Clue\Redis\Protocol\Model;
4
5 use Clue\Redis\Protocol\Model\ModelInterface;
6 use Clue\Redis\Protocol\Model\BulkReply;
7 use Clue\Redis\Protocol\Model\MultiBulkReply;
8 use Clue\Redis\Protocol\Serializer\SerializerInterface;
9
10 class Request implements ModelInterface
11 {
12 private $command;
13 private $args;
14
15 public function __construct($command, array $args = array())
16 {
17 $this->command = $command;
18 $this->args = $args;
19 }
20
21 public function getCommand()
22 {
23 return $this->command;
24 }
25
26 public function getArgs()
27 {
28 return $this->args;
29 }
30
31 public function getReplyModel()
32 {
33 $models = array(new BulkReply($this->command));
34 foreach ($this->args as $arg) {
35 $models []= new BulkReply($arg);
36 }
37
38 return new MultiBulkReply($models);
39 }
40
41 public function getValueNative()
42 {
43 $ret = $this->args;
44 array_unshift($ret, $this->command);
45
46 return $ret;
47 }
48
49 public function getMessageSerialized(SerializerInterface $serializer)
50 {
51 return $serializer->getRequestMessage($this->command, $this->args);
52 }
53 }