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

CollectionFilter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 41
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getJobsFromCollections() 0 15 2
A logErrorsFromCollection() 0 8 3
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