1 | <?php |
||
71 | class Client |
||
72 | { |
||
73 | /** |
||
74 | * @var ServiceFactoryInterface |
||
75 | */ |
||
76 | protected $serviceFactory; |
||
77 | |||
78 | /** |
||
79 | * Service options. |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $options = []; |
||
83 | |||
84 | /** |
||
85 | * Client constructor with overloading. |
||
86 | * |
||
87 | * @param array ...$args # The order of the arguments doesn't matter. |
||
88 | * Credentials is required, it can be CredentialsInterface instance or |
||
89 | * login and token strings in order. |
||
90 | * Example: |
||
91 | * $client = new Client('login', 'token'); |
||
92 | * $client = new Client(new Credentials('login', 'token')); |
||
93 | * $client = new Client(new Credentials('login', 'token'), ['useOperatorUnits' => true]); |
||
94 | * $client = new Client('login', 'token', ['useOperatorUnits' => true]); |
||
95 | * $client = new Client('login', 'token', new Transport(['logger' => new Log]), ['useOperatorUnits' => true]); |
||
96 | * // etc |
||
97 | */ |
||
98 | 34 | public function __construct(...$args) |
|
124 | |||
125 | /** |
||
126 | * Returns specific Service instance. |
||
127 | * |
||
128 | * @param string $serviceName # The Name of Yandex service |
||
129 | * @param array $args # The First argument is the service options override. |
||
130 | * @return Service |
||
131 | */ |
||
132 | 34 | public function __call($serviceName, array $args = []) |
|
141 | |||
142 | /** |
||
143 | * Alias of __call() |
||
144 | * |
||
145 | * @param string $name |
||
146 | * @return Service |
||
147 | * @see Client::__call() |
||
148 | */ |
||
149 | 17 | public function __get($name) |
|
153 | |||
154 | /* Setters & Getters */ |
||
155 | |||
156 | /** |
||
157 | * @param CredentialsInterface $credentials |
||
158 | * @return $this |
||
159 | */ |
||
160 | 34 | public function setCredentials($credentials) |
|
165 | |||
166 | /** |
||
167 | * @param TransportInterface $transport |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function setTransport($transport) |
||
175 | |||
176 | /** |
||
177 | * @param array $options |
||
178 | * @return $this |
||
179 | */ |
||
180 | public function setOptions($options) |
||
185 | |||
186 | /** |
||
187 | * @param ServiceFactoryInterface $serviceFactory |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function setServiceFactory($serviceFactory) |
||
195 | |||
196 | /** |
||
197 | * @return ServiceFactoryInterface |
||
198 | */ |
||
199 | 34 | protected function getServiceFactory() |
|
206 | } |
||
207 |