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