Completed
Pull Request — master (#11)
by Karl
02:49
created

SearchRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 48
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 6 1
A getActive() 0 8 2
1
<?php namespace JobApis\JobsToMail\Repositories;
2
3
use JobApis\JobsToMail\Models\Search;
4
5
class SearchRepository implements Contracts\SearchRepositoryInterface
6
{
7
    /**
8
     * @var Search model
9
     */
10
    public $searches;
11
12
    /**
13
     * SearchRepository constructor.
14
     *
15
     * @param Search $model
0 ignored issues
show
Bug introduced by
There is no parameter named $model. 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...
16
     */
17 4
    public function __construct(Search $searches)
18
    {
19 4
        $this->searches = $searches;
20 4
    }
21
22
    /**
23
     * Create a single search for a user
24
     *
25
     * @param string $userId
26
     * @param array $data
27
     *
28
     * @return Search
29
     */
30 1
    public function create($userId = null, $data = [])
31
    {
32 1
        return $this->searches->create(
33 1
            array_merge(['user_id' => $userId], $data)
34
        );
35
    }
36
37
    /**
38
     * Get all active searches from confirmed users
39
     *
40
     * @param null | string $userEmail
41
     *
42
     * @return \Illuminate\Database\Eloquent\Collection
43
     */
44 2
    public function getActive($userEmail = null)
45
    {
46 2
        $query = $this->searches->active();
47 2
        if ($userEmail) {
48 1
            $query = $query->whereUserEmail($userEmail);
49
        }
50 2
        return $query->get();
51
    }
52
}
53