1: | <?php |
2: | namespace Worldline\Connect\Sdk\Communication; |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | class ResponseClassMap |
10: | { |
11: | |
12: | public $defaultSuccessResponseClassName = ''; |
13: | |
14: | |
15: | public $defaultErrorResponseClassName = ''; |
16: | |
17: | |
18: | private $responseClassNamesByHttpStatusCode = array(); |
19: | |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | public function addResponseClassName($httpStatusCode, $responseClassName) |
26: | { |
27: | $this->responseClassNamesByHttpStatusCode[$httpStatusCode] = $responseClassName; |
28: | return $this; |
29: | } |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | public function getResponseClassName($httpStatusCode) |
36: | { |
37: | if (array_key_exists($httpStatusCode, $this->responseClassNamesByHttpStatusCode)) { |
38: | return $this->responseClassNamesByHttpStatusCode[$httpStatusCode]; |
39: | } |
40: | if ($httpStatusCode < 400) { |
41: | return $this->defaultSuccessResponseClassName; |
42: | } |
43: | return $this->defaultErrorResponseClassName; |
44: | } |
45: | } |
46: | |