1 | <?php |
||
15 | abstract class Operator implements OperatorInterface |
||
16 | { |
||
17 | /** @var ClientInterface */ |
||
18 | private $client; |
||
19 | |||
20 | /** @var ApiInterface */ |
||
21 | protected $api; |
||
22 | |||
23 | /** |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | 232 | public function __construct(ClientInterface $client, ApiInterface $api) |
|
31 | |||
32 | /** |
||
33 | * Magic method for dictating how objects are rendered when var_dump is called. |
||
34 | * For the benefit of users, extremely verbose and heavy properties (such as HTTP clients) are |
||
35 | * removed to provide easier access to normal state, such as resource attributes. |
||
36 | * |
||
37 | * @codeCoverageIgnore |
||
38 | * @return array |
||
39 | */ |
||
40 | public function __debugInfo() |
||
54 | |||
55 | /** |
||
56 | * Retrieves a populated Operation according to the definition and values provided. A |
||
57 | * HTTP client is also injected into the object to allow it to communicate with the remote API. |
||
58 | * |
||
59 | * @param array $definition The data that dictates how the operation works |
||
60 | * |
||
61 | * @return Operation |
||
62 | */ |
||
63 | 177 | public function getOperation(array $definition) |
|
67 | |||
68 | 176 | protected function sendRequest(Operation $operation, array $userValues = [], $async = false) |
|
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | 148 | public function execute(array $definition, array $userValues = []) |
|
84 | |||
85 | /** |
||
86 | * {@inheritDoc} |
||
87 | */ |
||
88 | public function executeAsync(array $definition, array $userValues = []) |
||
92 | |||
93 | /** |
||
94 | * {@inheritDoc} |
||
95 | */ |
||
96 | 84 | public function model($class, $data = null) |
|
114 | |||
115 | /** |
||
116 | * Will create a new instance of this class with the current HTTP client and API injected in. This |
||
117 | * is useful when enumerating over a collection since multiple copies of the same resource class |
||
118 | * are needed. |
||
119 | * |
||
120 | * @return static |
||
121 | */ |
||
122 | 32 | public function newInstance() |
|
126 | |||
127 | /** |
||
128 | * @return \GuzzleHttp\Psr7\Uri |
||
129 | */ |
||
130 | 2 | protected function getHttpBaseUrl() |
|
134 | |||
135 | /** |
||
136 | * Magic method which intercepts async calls, finds the sequential version, and wraps it in a |
||
137 | * {@see Promise} object. In order for this to happen, the called methods need to be in the |
||
138 | * following format: `createAsync`, where `create` is the sequential method being wrapped. |
||
139 | * |
||
140 | * @param $methodName The name of the method being invoked. |
||
141 | * @param $args The arguments to be passed to the sequential method. |
||
142 | * |
||
143 | * @throws \RuntimeException If method does not exist |
||
144 | * |
||
145 | * @return Promise |
||
146 | */ |
||
147 | 3 | public function __call($methodName, $args) |
|
171 | } |