1 | <?php |
||
14 | abstract class Driver implements SerializableForQueue |
||
15 | { |
||
16 | /** @var array */ |
||
17 | protected $parameters; |
||
18 | |||
19 | /** @var HttpRequest */ |
||
20 | protected $request; |
||
21 | |||
22 | /** @var Client */ |
||
23 | protected $http; |
||
24 | |||
25 | 1 | public function __construct(Client $http) |
|
26 | { |
||
27 | 1 | $this->http = $http; |
|
28 | 1 | } |
|
29 | |||
30 | /** |
||
31 | * Fill driver with parameters and http request instance. |
||
32 | * |
||
33 | * @param array $parameters |
||
34 | * @param HttpRequest $request |
||
35 | */ |
||
36 | 1 | public function fill(array $parameters, HttpRequest $request): void |
|
41 | |||
42 | /** |
||
43 | * @return Client |
||
44 | */ |
||
45 | 1 | public function getHttp(): Client |
|
46 | { |
||
47 | 1 | return $this->http; |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * Get parameter value. |
||
52 | * |
||
53 | * @param string $name |
||
54 | * @param null $default |
||
55 | * |
||
56 | * @return mixed |
||
57 | */ |
||
58 | 1 | public function getParameter(string $name, $default = null) |
|
62 | |||
63 | /** |
||
64 | * Get template compiler instance. |
||
65 | * |
||
66 | * @return TemplateCompiler|null |
||
67 | */ |
||
68 | abstract public function getTemplateCompiler(): ?TemplateCompiler; |
||
69 | |||
70 | /** |
||
71 | * Get command handler instance. |
||
72 | * |
||
73 | * @return CommandHandler |
||
74 | */ |
||
75 | abstract public function getCommandHandler(): CommandHandler; |
||
76 | |||
77 | /** |
||
78 | * Verify incoming request data. |
||
79 | * |
||
80 | * @throws InvalidRequest |
||
81 | */ |
||
82 | abstract public function verifyRequest(): void; |
||
83 | |||
84 | /** |
||
85 | * Get current chat. |
||
86 | * |
||
87 | * @return Chat |
||
88 | */ |
||
89 | abstract public function getChat(): Chat; |
||
90 | |||
91 | /** |
||
92 | * Get current user. |
||
93 | * |
||
94 | * @return User |
||
95 | */ |
||
96 | abstract public function getUser(): User; |
||
97 | |||
98 | /** |
||
99 | * Get message received from sender. |
||
100 | * |
||
101 | * @return ReceivedMessage |
||
102 | */ |
||
103 | abstract public function getMessage(): ReceivedMessage; |
||
104 | |||
105 | /** |
||
106 | * Handle command. |
||
107 | * |
||
108 | * @param Command $command |
||
109 | * |
||
110 | * @throws RuntimeException |
||
111 | */ |
||
112 | 1 | public function handle(Command $command): void |
|
116 | } |
||
117 |