1 | <?php namespace JobApis\JobsToMail\Jobs; |
||
13 | class SearchAndNotifyUser implements ShouldQueue |
||
14 | { |
||
15 | use InteractsWithQueue, Queueable, SerializesModels; |
||
16 | |||
17 | /** |
||
18 | * @var Search search to conduct |
||
19 | */ |
||
20 | protected $search; |
||
21 | |||
22 | /** |
||
23 | * The maximum number of jobs to return |
||
24 | */ |
||
25 | const MAX_JOBS = 50; |
||
26 | |||
27 | /** |
||
28 | * The maximum number of jobs from each provider |
||
29 | */ |
||
30 | const MAX_JOBS_FROM_PROVIDER = 10; |
||
31 | |||
32 | /** |
||
33 | * The maximum age of a job to be included |
||
34 | */ |
||
35 | const MAX_DAYS_OLD = 14; |
||
36 | |||
37 | /** |
||
38 | * Create a new job instance. |
||
39 | */ |
||
40 | 6 | public function __construct(Search $search) |
|
44 | |||
45 | /** |
||
46 | * Collect and sort jobs from multiple APIs using the JobsMulti client. |
||
47 | * |
||
48 | * @param JobsMulti $jobsClient |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | 6 | public function handle(JobsMulti $jobsClient) |
|
72 | |||
73 | /** |
||
74 | * Convert the array of collections to one large array |
||
75 | * |
||
76 | * @param array $collectionsArray |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | 6 | protected function getJobsFromCollections($collectionsArray = []) |
|
99 | |||
100 | /** |
||
101 | * Logs all the errors attached to a collection |
||
102 | * |
||
103 | * @param array $jobsByProvider |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | 6 | protected function logErrorsFromCollection(Collection $collection) |
|
115 | |||
116 | /** |
||
117 | * Sort jobs by date posted, desc |
||
118 | * |
||
119 | * @param array $jobs |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | 6 | protected function sortJobs($jobs = []) |
|
136 | } |
||
137 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.