AdzunaQuery::getKeyword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace JobApis\Jobs\Client\Queries;
2
3
class AdzunaQuery extends AbstractQuery
4
{
5
    /**
6
     * country
7
     *
8
     * ISO 8601 country code of the relevant country. Allowed choices:
9
     * gb
10
     * au
11
     * br
12
     * ca
13
     * de
14
     * fr
15
     * in
16
     * nl
17
     * pl
18
     * ru
19
     * za
20
     *
21
     * @var string
22
     */
23
    protected $country;
24
25
    /**
26
     * app_id
27
     *
28
     * Application ID, supplied by Adzuna.
29
     *
30
     * @var string
31
     */
32
    protected $app_id;
33
34
    /**
35
     * app_key
36
     *
37
     * Application key, supplied by Adzuna
38
     *
39
     * @var string
40
     */
41
    protected $app_key;
42
43
    /**
44
     * page
45
     *
46
     * Page number
47
     *
48
     * @var integer
49
     */
50
    protected $page;
51
52
    /**
53
     * results_per_page
54
     *
55
     * The number of results to include on each page of search results.
56
     *
57
     * @var integer
58
     */
59
    protected $results_per_page;
60
61
    /**
62
     * what
63
     *
64
     * The keywords to search for. Use space or comma characters to separate multiple keywords.
65
     *
66
     * @var string
67
     */
68
    protected $what;
69
70
    /**
71
     * what_and
72
     *
73
     * The keywords to search for, all keywords must be found.
74
     *
75
     * @var string
76
     */
77
    protected $what_and;
78
79
    /**
80
     * what_phrase
81
     *
82
     * An entire phrase which must be found in the description or title.
83
     *
84
     * @var string
85
     */
86
    protected $what_phrase;
87
88
    /**
89
     * what_or
90
     *
91
     * Keywords to search for. Use space or comma characters to separate multiple keywords.
92
     *
93
     * @var string
94
     */
95
    protected $what_or;
96
97
    /**
98
     * what_exclude
99
     *
100
     * Keywords to exclude from the search. Use space or comma characters to separate multiple keywords.
101
     *
102
     * @var string
103
     */
104
    protected $what_exclude;
105
106
    /**
107
     * title_only
108
     *
109
     * Keywords to find, but only in the title. Use space or comma characters to separate multiple keywords.
110
     *
111
     * @var string
112
     */
113
    protected $title_only;
114
115
    /**
116
     * location0
117
     *
118
     * The locationN fields may be used to describe a location, in a similar form to that
119
     * returned in a Adzuna::API::Response::Location object. For example,
120
     * "location0=UK&location1=South East England&location2=Surrey" will perform a search
121
     * over the county of Surrey.
122
     *
123
     * @var string
124
     */
125
    protected $location0;
126
127
    /**
128
     * location1
129
     *
130
     * See location0 above.
131
     *
132
     * @var string
133
     */
134
    protected $location1;
135
136
    /**
137
     * location2
138
     *
139
     * See location0 above.
140
     *
141
     * @var string
142
     */
143
    protected $location2;
144
145
    /**
146
     * location3
147
     *
148
     * See location0 above.
149
     *
150
     * @var string
151
     */
152
    protected $location3;
153
154
    /**
155
     * location4
156
     *
157
     * See location0 above.
158
     *
159
     * @var string
160
     */
161
    protected $location4;
162
163
    /**
164
     * location5
165
     *
166
     * See location0 above.
167
     *
168
     * @var string
169
     */
170
    protected $location5;
171
172
    /**
173
     * location6
174
     *
175
     * See location0 above.
176
     *
177
     * @var string
178
     */
179
    protected $location6;
180
181
    /**
182
     * location7
183
     *
184
     * See location0 above.
185
     *
186
     * @var string
187
     */
188
    protected $location7;
189
190
    /**
191
     * where
192
     *
193
     * The geographic centre of the search. Place names or postal codes may be used.
194
     *
195
     * @var string
196
     */
197
    protected $where;
198
199
    /**
200
     * distance
201
     *
202
     * The distance in kilometres from the centre of the place described by the 'where' parameter.
203
     * Defaults to 10km.
204
     *
205
     * @var string
206
     */
207
    protected $distance;
208
209
    /**
210
     * max_days_old
211
     *
212
     * The age of the oldest advertisment in days that will be returned.
213
     *
214
     * @var string
215
     */
216
    protected $max_days_old;
217
218
    /**
219
     * category
220
     *
221
     * The category tag, as returned by the "category" endpoint.
222
     *
223
     * @var string
224
     */
225
    protected $category;
226
227
    /**
228
     * sort_direction
229
     *
230
     * The order of search results (ascending or descending).
231
     *
232
     * @var string
233
     */
234
    protected $sort_direction;
235
236
    /**
237
     * sort_by
238
     *
239
     * The ordering of the search results.
240
     *
241
     * @var string
242
     */
243
    protected $sort_by;
244
245
    /**
246
     * salary_min
247
     *
248
     * The minimum salary we wish to get results for.
249
     *
250
     * @var string
251
     */
252
    protected $salary_min;
253
254
    /**
255
     * salary_max
256
     *
257
     * The maximum salary we wish to get results for.
258
     *
259
     * @var string
260
     */
261
    protected $salary_max;
262
263
    /**
264
     * salary_include_unknown
265
     *
266
     * When using salary_min and/or salary_max set this to "1", to include jobs with unknown salaries in results.
267
     *
268
     * @var boolean
269
     */
270
    protected $salary_include_unknown;
271
272
    /**
273
     * full_time
274
     *
275
     * If set to "1", only full time jobs will be returned.
276
     *
277
     * @var boolean
278
     */
279
    protected $full_time;
280
281
    /**
282
     * part_time
283
     *
284
     * If set to "1", only part time jobs will be returned.
285
     *
286
     * @var boolean
287
     */
288
    protected $part_time;
289
290
    /**
291
     * contract
292
     *
293
     * If set to "1", only contract jobs will be returned.
294
     *
295
     * @var boolean
296
     */
297
    protected $contract;
298
299
    /**
300
     * permanent
301
     *
302
     * If set to "1", only permanent jobs will be returned.
303
     *
304
     * @var boolean
305
     */
306
    protected $permanent;
307
308
    /**
309
     * company
310
     *
311
     * The canonical company name. This may be returned in a Adzuna::API::Response::Company object
312
     * when a job is returned. A full list of allowed terms in not available through the API.
313
     *
314
     * @var string
315
     */
316
    protected $company;
317
318
    /**
319
     * Get baseUrl
320
     *
321
     * @return  string Value of the base url to this api
322
     */
323 6
    public function getBaseUrl()
324
    {
325 6
        return 'http://api.adzuna.com/v1/api/jobs';
326
    }
327
328
    /**
329
     * Get keyword
330
     *
331
     * @return string Attribute being used as the search keyword
332
     */
333 4
    public function getKeyword()
334
    {
335 4
        return $this->what;
336
    }
337
338
    /**
339
     * Get url
340
     *
341
     * @return  string
342
     */
343 4
    public function getUrl()
344
    {
345 4
        return $this->getBaseUrl().'/'.$this->country.'/search/'.$this->page.'/'.$this->getQueryString();
346
    }
347
348
    /**
349
     * Default parameters
350
     *
351
     * @var array
352
     */
353 20
    protected function defaultAttributes()
354
    {
355
        return [
356 20
            'page' => '1',
357 20
        ];
358
    }
359
360
    /**
361
     * Gets the attributes to use for this API's query
362
     *
363
     * @var array
364
     */
365 4
    protected function getQueryAttributes()
366
    {
367 4
        $attributes = get_object_vars($this);
368 4
        unset($attributes['country']);
369 4
        unset($attributes['page']);
370 4
        return $attributes;
371
    }
372
373
    /**
374
     * Required parameters
375
     *
376
     * @return array
377
     */
378 6
    protected function requiredAttributes()
379
    {
380
        return [
381 6
            'country',
382 6
            'app_id',
383 6
            'app_key',
384 6
            'page',
385 6
        ];
386
    }
387
}
388