1 | <?php |
||
9 | class RequestsContainer |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var HttpClient |
||
14 | */ |
||
15 | protected $http; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $login; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $password; |
||
26 | |||
27 | /** |
||
28 | * @var Request[] |
||
29 | */ |
||
30 | protected $requests = []; |
||
31 | |||
32 | public function __construct(HttpClient $http, $login, $password) |
||
38 | |||
39 | /** |
||
40 | * @return array |
||
41 | */ |
||
42 | protected function getRequestsActionsMap() |
||
49 | |||
50 | /** |
||
51 | * Proxies all methods to the appropriate Request object |
||
52 | * |
||
53 | * @param string $method |
||
54 | * @param array $arguments |
||
55 | * @return array |
||
56 | */ |
||
57 | public function __call($method, $arguments) |
||
63 | |||
64 | /** |
||
65 | * Gets request object by name. If there is no such request |
||
66 | * in requests array, it will try to create it, then save |
||
67 | * it, and then return. |
||
68 | * |
||
69 | * @param string $requestClass |
||
70 | * |
||
71 | * @throws WrongRequest |
||
72 | * |
||
73 | * @return Request |
||
74 | */ |
||
75 | public function getRequest($requestClass) |
||
83 | |||
84 | /** |
||
85 | * @param $action |
||
86 | * @return string |
||
87 | * @throws WrongRequest |
||
88 | */ |
||
89 | public function resolveRequestByAction($action) |
||
99 | |||
100 | /** |
||
101 | * Creates request by class name, and if success saves |
||
102 | * it to requests array. |
||
103 | * |
||
104 | * @param string $requestClass |
||
105 | * |
||
106 | * @throws WrongRequest |
||
107 | */ |
||
108 | protected function addRequest($requestClass) |
||
115 | |||
116 | /** |
||
117 | * Build RequestInterface object with reflection API. |
||
118 | * |
||
119 | * @param string $className |
||
120 | * |
||
121 | * @return object |
||
122 | */ |
||
123 | protected function buildRequest($className) |
||
129 | } |