Completed
Push — master ( e48405...3cf851 )
by Karl
27s
created

CollectionFilter::getJobsFromCollections()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 1
nop 2
crap 2
1
<?php namespace JobApis\JobsToMail\Filters;
2
3
use Illuminate\Support\Facades\Log;
4
use JobApis\Jobs\Client\Collection;
5
6
class CollectionFilter
7
{
8
    /**
9
     * Convert the array of collections to one large array of Jobs
10
     *
11
     * @param array $collectionsArray
12
     *
13
     * @return array
14
     */
15 2
    public function getJobsFromCollections($collectionsArray = [], $max = 50)
16
    {
17 2
        $jobs = [];
18 2
        array_walk_recursive(
19
            $collectionsArray,
20 2
            function (Collection $collection) use (&$jobs, $max) {
21 2
                $this->logErrorsFromCollection($collection);
22 2
                $jobListings = array_slice($collection->all(), 0, $max);
23 2
                foreach ($jobListings as $jobListing) {
24 2
                    $jobs[] = $jobListing;
25
                }
26 2
            }
27
        );
28 2
        return $jobs;
29
    }
30
31
    /**
32
     * Logs all the errors attached to a collection
33
     *
34
     * @param array $jobsByProvider
0 ignored issues
show
Bug introduced by
There is no parameter named $jobsByProvider. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
35
     *
36
     * @return void
37
     */
38 2
    protected function logErrorsFromCollection(Collection $collection)
39
    {
40 2
        if ($collection->getErrors()) {
41 1
            foreach ($collection->getErrors() as $error) {
42 1
                Log::error($error);
43
            }
44
        }
45 2
    }
46
}
47