1 | <?php |
||
15 | class Server |
||
16 | { |
||
17 | /** |
||
18 | * @var string array |
||
19 | */ |
||
20 | private $payload; |
||
21 | |||
22 | /** |
||
23 | * @var Processor |
||
24 | */ |
||
25 | private $processor; |
||
26 | |||
27 | /** |
||
28 | * @var RequestParser |
||
29 | */ |
||
30 | private $requestParser; |
||
31 | |||
32 | /** |
||
33 | * @var ResponseBuilder |
||
34 | */ |
||
35 | private $responseBuilder; |
||
36 | |||
37 | /** |
||
38 | * Server constructor. |
||
39 | * |
||
40 | * @param string $payload |
||
41 | */ |
||
42 | public function __construct(string $payload = null) |
||
50 | |||
51 | /** |
||
52 | * @return RequestParser |
||
53 | */ |
||
54 | public function getRequestParser(): RequestParser |
||
58 | |||
59 | /** |
||
60 | * @return ResponseBuilder |
||
61 | */ |
||
62 | public function getResponseBuilder(): ResponseBuilder |
||
66 | |||
67 | /** |
||
68 | * Add handler-object for handling request |
||
69 | * |
||
70 | * @param mixed $object |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function addHandler($object) |
||
78 | |||
79 | /** |
||
80 | * Set mapper-object for mapping request-method on class and method |
||
81 | * |
||
82 | * @param MapperInterface $mapper |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function setMapper(MapperInterface $mapper) |
||
86 | { |
||
87 | $this->processor->setMapper($mapper); |
||
88 | return $this; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Run server |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function execute(): string |
||
103 | } |
||
104 |