Completed
Push — master ( b618f7...e48405 )
by Karl
11s
created

SearchRepository::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
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 6
    public function __construct(Search $searches)
18
    {
19 6
        $this->searches = $searches;
20 6
    }
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
     * Delete a search by ID
39
     *
40
     * @param string $id
41
     *
42
     * @return boolean
43
     */
44 1
    public function delete($id = null)
45
    {
46 1
        return $this->searches->where('id', $id)->delete();
47
    }
48
49
    /**
50
     * Get all active searches from confirmed users
51
     *
52
     * @param null | string $userEmail
53
     *
54
     * @return \Illuminate\Database\Eloquent\Collection
55
     */
56 2
    public function getActive($userEmail = null)
57
    {
58 2
        $query = $this->searches->active();
59 2
        if ($userEmail) {
60 1
            $query = $query->whereUserEmail($userEmail);
61
        }
62 2
        return $query->get();
63
    }
64
65
    /**
66
     * Get searches by User Id
67
     *
68
     * @param string $userId
69
     *
70
     * @return \Illuminate\Database\Eloquent\Collection
71
     */
72 1
    public function getByUserId($userId = null)
73
    {
74 1
        return $this->searches->whereUserId($userId)->get();
75
    }
76
}
77