Conditions | 6 |
Paths | 32 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 6 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
44 | 1 | public function search(array $filters = []) |
|
45 | { |
||
46 | 1 | $collection = new JobCollection; |
|
47 | 1 | $search = ['affid' => $this->affiliateId]; |
|
48 | 1 | if (isset($filters['keywords'])) { // empty allowed |
|
49 | 1 | $search['keywords'] = $filters['keywords']; |
|
50 | 1 | } |
|
51 | 1 | if (isset($filters['location'])) { // empty allowed |
|
52 | 1 | $search['location'] = $filters['location']; |
|
53 | 1 | } |
|
54 | 1 | if (isset($filters['limit'])) { // max 99 |
|
55 | 1 | $search['pagesize'] = $filters['limit']; |
|
56 | 1 | } |
|
57 | 1 | $search['page'] = isset($filters['offset']) ? $filters['offset'] : 1; // starts on 1 |
|
58 | |||
59 | 1 | $result = $this->api->search($search); |
|
60 | 1 | foreach ($result->jobs as $job) { |
|
61 | 1 | $collection->addJob(JobBuilder::fromApi($job, $this->country)); |
|
62 | 1 | } |
|
63 | |||
64 | 1 | return $collection; |
|
65 | } |
||
66 | } |
||
67 |