1 | <?php |
||
18 | class Service |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $endpoint; |
||
24 | |||
25 | /** |
||
26 | * @var ErrorFormatter |
||
27 | */ |
||
28 | protected $errorFormatter; |
||
29 | |||
30 | /** |
||
31 | * @var Method[] |
||
32 | */ |
||
33 | protected $methods = []; |
||
34 | |||
35 | /** |
||
36 | * @param string $endpoint |
||
37 | * @param ErrorFormatter|null $errorFormatter |
||
38 | */ |
||
39 | 39 | public function __construct($endpoint, ErrorFormatter $errorFormatter = null) |
|
44 | |||
45 | /** |
||
46 | * @param string $message |
||
47 | * |
||
48 | * @return AbstractResponse[]|AbstractResponse|null |
||
49 | * |
||
50 | * @throws \Exception |
||
51 | */ |
||
52 | 33 | public function dispatch($message) |
|
78 | |||
79 | /** |
||
80 | * @param Method $method |
||
81 | */ |
||
82 | 21 | public function add(Method $method) |
|
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | 6 | public function endpoint() |
|
94 | |||
95 | /** |
||
96 | * @return Method[] |
||
97 | */ |
||
98 | 18 | public function methods() |
|
102 | |||
103 | /** |
||
104 | * @param string $methodName |
||
105 | * |
||
106 | * @return Method |
||
107 | * |
||
108 | * @throws MethodNotFound |
||
109 | */ |
||
110 | 18 | public function findMethodBy($methodName) |
|
118 | |||
119 | /** |
||
120 | * @param RequestBuilder $requestBuilder |
||
121 | * |
||
122 | * @return AbstractResponse[]|null |
||
123 | */ |
||
124 | 12 | protected function buildResponses(RequestBuilder $requestBuilder) |
|
147 | |||
148 | /** |
||
149 | * @param AbstractRequest $request |
||
150 | * |
||
151 | * @return null|SuccessfulResponse |
||
152 | * |
||
153 | * @throws \Exception |
||
154 | */ |
||
155 | 15 | protected function buildResponse(AbstractRequest $request) |
|
174 | } |
||
175 |