1 | <?php |
||
11 | class Event |
||
12 | { |
||
13 | private $time; |
||
14 | private $class; |
||
15 | private $request; |
||
16 | private $response; |
||
17 | |||
18 | 59 | public function __construct($time, $class, $request, $response) |
|
25 | |||
26 | 1 | public function render(Manager $manager) |
|
27 | { |
||
28 | 1 | switch ($this->class) { |
|
29 | 1 | case Connection::class: |
|
30 | 1 | return 'Make connection'; |
|
31 | |||
32 | 1 | case EvaluateRequest::class: |
|
33 | return $this->request[39]; |
||
34 | |||
35 | 1 | case SelectRequest::class: |
|
|
|||
36 | |||
37 | 1 | $params = $this->request[IProto::KEY]; |
|
38 | 1 | $spaceId = $this->request[IProto::SPACE_ID]; |
|
39 | 1 | $index = $this->request[IProto::INDEX_ID]; |
|
40 | |||
41 | 1 | $client = $manager->getClient(); |
|
42 | 1 | $meta = $manager->getMeta(); |
|
43 | 1 | $schema = $manager->getSchema(); |
|
44 | 1 | $space = $schema->getSpaceName($spaceId); |
|
45 | |||
46 | 1 | if ($meta->has($space)) { |
|
47 | 1 | $index = $meta->get($space)->getIndex($index); |
|
48 | 1 | } else { |
|
49 | $data = $client->getSpace('_vindex')->select([$this->request[IProto::SPACE_ID], $index], 'primary')->getData(); |
||
50 | $index = []; |
||
51 | foreach ($data[0][5] as $row) { |
||
52 | $index[] = $row[0]; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | 1 | if (count($params) == 1) { |
|
57 | 1 | $params = array_shift($params); |
|
58 | 1 | $index = array_shift($index); |
|
59 | 1 | } else { |
|
60 | $params = json_encode($params); |
||
61 | $index = json_encode($index); |
||
62 | } |
||
63 | |||
64 | 1 | return "select $space where $index = $params"; |
|
65 | default: |
||
66 | return json_encode($this->request); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | public function getTime() |
||
74 | |||
75 | 1 | public function getResponse() |
|
79 | } |
||
80 |
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.