123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace Predis\Command;
- class ServerClient extends AbstractCommand
- {
-
- public function getId()
- {
- return 'CLIENT';
- }
-
- public function parseResponse($data)
- {
- $args = array_change_key_case($this->getArguments(), CASE_UPPER);
- switch (strtoupper($args[0])) {
- case 'LIST':
- return $this->parseClientList($data);
- case 'KILL':
- default:
- return $data;
- }
- }
-
- protected function parseClientList($data)
- {
- $clients = array();
- foreach (explode("\n", $data, -1) as $clientData) {
- $client = array();
- foreach (explode(' ', $clientData) as $kv) {
- @list($k, $v) = explode('=', $kv);
- $client[$k] = $v;
- }
- $clients[] = $client;
- }
- return $clients;
- }
- }
|