1 | <?php |
||
15 | abstract class AbstractResponseParser implements ResponseParserInterface |
||
16 | { |
||
17 | protected static $generalErrorResponses = [ |
||
18 | Response::ERROR_BAD_FORMAT => BadFormatException::class, |
||
19 | Response::ERROR_INTERNAL_ERROR => InternalErrorException::class, |
||
20 | Response::ERROR_OUT_OF_MEMORY => OutOfMemoryException::class, |
||
21 | Response::ERROR_UNKNOWN_COMMAND => UnknownCommandException::class |
||
22 | ]; |
||
23 | |||
24 | /** @var string[] */ |
||
25 | private $acceptableResponses = []; |
||
26 | |||
27 | /** @var array */ |
||
28 | private $expectedErrorResponses = []; |
||
29 | |||
30 | /** |
||
31 | * @param string[] $acceptableResponses |
||
32 | * @param string[] $expectedErrorResponses |
||
33 | */ |
||
34 | 56 | public function __construct(array $acceptableResponses = [], array $expectedErrorResponses = []) |
|
39 | |||
40 | /** |
||
41 | * @param string $responseLine |
||
42 | * @param Server $server |
||
43 | * @return Response |
||
44 | * @throws UnexpectedResponseException |
||
45 | */ |
||
46 | abstract public function parseResponse($responseLine, Server $server); |
||
47 | |||
48 | /** |
||
49 | * @param string $responseLine |
||
50 | * @return string |
||
51 | */ |
||
52 | 7 | protected function getResponseName($responseLine) |
|
59 | |||
60 | /** |
||
61 | * @param string $responseName |
||
62 | * @param Server $server |
||
63 | * @throws UnexpectedResponseException |
||
64 | */ |
||
65 | 7 | protected function ensureValidResponseName($responseName, Server $server) |
|
75 | } |
||
76 |