1 | <?php |
||
12 | class MusicInfo |
||
13 | { |
||
14 | use PropertyTrait; |
||
15 | /** |
||
16 | * @var ClientInterface |
||
17 | */ |
||
18 | protected $client; |
||
19 | |||
20 | /** |
||
21 | * @var ArrayCollection |
||
22 | */ |
||
23 | protected $services; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $config; |
||
29 | |||
30 | /** |
||
31 | * Supported Services |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $supportedServices = []; |
||
35 | |||
36 | /** |
||
37 | * MusicInfo constructor. |
||
38 | * @param $config |
||
39 | * @throws ServiceConfigurationException if musicinfo.service is missing |
||
40 | */ |
||
41 | 19 | public function __construct($config) |
|
62 | |||
63 | /** |
||
64 | * @param ClientInterface $client |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | 19 | public function setClient(ClientInterface $client) |
|
74 | |||
75 | /** |
||
76 | * @return ClientInterface |
||
77 | */ |
||
78 | 19 | public function getClient() |
|
82 | |||
83 | /** |
||
84 | * Load service |
||
85 | * |
||
86 | * @param $service |
||
87 | * @param $init |
||
88 | * |
||
89 | * @return IMusicService |
||
90 | * |
||
91 | * @throws \Exception |
||
92 | */ |
||
93 | 19 | public function loadService($service, $init = false) |
|
110 | |||
111 | /** |
||
112 | * Merge shared config with service specific configuration |
||
113 | * |
||
114 | * @param $service |
||
115 | * @return array |
||
116 | */ |
||
117 | 19 | public function mergeConfig($service) |
|
130 | |||
131 | /** |
||
132 | * Load all services |
||
133 | * |
||
134 | * @param bool $initialize |
||
135 | * |
||
136 | * @return ArrayCollection |
||
137 | * @throws \Exception |
||
138 | */ |
||
139 | 3 | public function loadServices($initialize = false) |
|
147 | |||
148 | /** |
||
149 | * @param IMusicService $service |
||
150 | * |
||
151 | * @return $this |
||
152 | */ |
||
153 | 19 | public function addService(IMusicService $service, $key) |
|
158 | |||
159 | /** |
||
160 | * @return ArrayCollection |
||
161 | */ |
||
162 | 3 | public function getServices() |
|
166 | |||
167 | /** |
||
168 | * @param $key |
||
169 | * @return BaseService|null |
||
170 | */ |
||
171 | 11 | public function getService($key) |
|
180 | |||
181 | /** |
||
182 | * @param BaseService $service |
||
183 | * |
||
184 | * @return BaseService |
||
185 | * @throws ServiceConfigurationException |
||
186 | */ |
||
187 | 10 | public function initializeService(BaseService $service) |
|
195 | |||
196 | /** |
||
197 | * @param string $key |
||
198 | * |
||
199 | * @return $this |
||
200 | */ |
||
201 | 1 | public function removeService($key) |
|
209 | |||
210 | /** |
||
211 | * @return BaseService|null |
||
212 | */ |
||
213 | 1 | public function getPreferredService() |
|
217 | |||
218 | /** |
||
219 | * Perform Multi-service search |
||
220 | * |
||
221 | * @param $argument |
||
222 | * @param $type |
||
223 | * @param null $servicesArg |
||
224 | * |
||
225 | * @return ArrayCollection |
||
226 | * @throws \Exception |
||
227 | */ |
||
228 | 5 | public function doSearch($argument, $type, $servicesArg = null) |
|
244 | |||
245 | /** |
||
246 | * Return an arraycollection with (loaded) services |
||
247 | * |
||
248 | * @param mixed $servicesArg |
||
249 | * |
||
250 | * @return ArrayCollection |
||
251 | * @throws \Exception |
||
252 | */ |
||
253 | 5 | protected function _prepareSearch($servicesArg = null) |
|
274 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.