1 | <?php |
||
20 | class RedisCli extends Abstraction implements Executable |
||
21 | { |
||
22 | /** |
||
23 | * List of implemented redis commands |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | private $availableCommands = ['BGSAVE' => true, 'LASTSAVE' => true]; |
||
28 | |||
29 | /** |
||
30 | * Redis command to execute |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $command; |
||
35 | |||
36 | /** |
||
37 | * Host to connect to |
||
38 | * -h |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | private $host; |
||
43 | |||
44 | /** |
||
45 | * Port to connect to |
||
46 | * -p |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | private $port; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Password to connect |
||
55 | * -a |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $password; |
||
60 | |||
61 | /** |
||
62 | * Constructor. |
||
63 | * |
||
64 | * @param string $path |
||
65 | */ |
||
66 | public function __construct($path = null) |
||
71 | |||
72 | /** |
||
73 | * Set the redis-cli command to execute. |
||
74 | * |
||
75 | * @param string $command |
||
76 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
77 | * @throws \phpbu\App\Exception |
||
78 | */ |
||
79 | public function runCommand($command) |
||
87 | |||
88 | /** |
||
89 | * Execute redis-cli BGSAVE command. |
||
90 | * |
||
91 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
92 | * @throws \phpbu\App\Exception |
||
93 | */ |
||
94 | public function backup() |
||
98 | |||
99 | /** |
||
100 | * Execute redis-cli LASTSAVE command. |
||
101 | * |
||
102 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
103 | * @throws \phpbu\App\Exception |
||
104 | */ |
||
105 | public function lastBackupTime() |
||
109 | |||
110 | /** |
||
111 | * Host to connect to. |
||
112 | * |
||
113 | * @param string $host |
||
114 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
115 | */ |
||
116 | public function useHost($host) |
||
121 | |||
122 | /** |
||
123 | * Port to connect to. |
||
124 | * |
||
125 | * @param integer $port |
||
126 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
127 | */ |
||
128 | public function usePort($port) |
||
133 | |||
134 | /** |
||
135 | * Password to authenticate. |
||
136 | * |
||
137 | * @param string $password |
||
138 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
139 | */ |
||
140 | public function usePassword($password) |
||
145 | |||
146 | /** |
||
147 | * RedisCli Process generator. |
||
148 | * |
||
149 | * @return \phpbu\App\Cli\Process |
||
150 | * @throws \phpbu\App\Exception |
||
151 | */ |
||
152 | protected function createProcess() |
||
172 | |||
173 | /** |
||
174 | * Set the openssl command line options |
||
175 | * |
||
176 | * @param \phpbu\App\Cli\Cmd $cmd |
||
177 | */ |
||
178 | protected function setOptions(Cmd $cmd) |
||
184 | } |
||
185 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.