1 | <?php |
||
7 | class Varnish |
||
8 | { |
||
9 | /* |
||
10 | * Known exec types |
||
11 | */ |
||
12 | const EXEC_SOCKET = 'socket'; |
||
13 | const EXEC_COMMAND = 'command'; |
||
14 | |||
15 | /** |
||
16 | * @param string|array $host |
||
17 | * |
||
18 | * @return bool|null |
||
19 | * |
||
20 | * @throws \Exception |
||
21 | */ |
||
22 | public function flush($host = null) |
||
45 | |||
46 | /** |
||
47 | * @param array|string $host |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | protected function getHosts($host = null): array |
||
61 | |||
62 | /** |
||
63 | * @param string $expr |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function generateBanCommand($expr = ''): string |
||
73 | |||
74 | /** |
||
75 | * @param array $hosts |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function generateBanExpr(array $hosts): string |
||
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | public function getSecret() |
||
109 | |||
110 | /** |
||
111 | * @param string $command |
||
112 | * |
||
113 | * @return bool |
||
114 | * |
||
115 | * @throws \Exception When the command fails |
||
116 | */ |
||
117 | protected function executeCommand(string $command): bool |
||
124 | |||
125 | /** |
||
126 | * @param string $command |
||
127 | * |
||
128 | * @return bool |
||
129 | * |
||
130 | * @throws \Exception When connection to socket or command failed |
||
131 | */ |
||
132 | protected function executeSocketCommand(string $command): bool |
||
150 | } |
||
151 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.