Delete::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
ccs 8
cts 8
cp 1
cc 2
nc 2
nop 1
crap 2
1
<?php namespace JobApis\JobsToMail\Jobs\Searches;
2
3
use JobApis\JobsToMail\Http\Messages\FlashMessage;
4
use JobApis\JobsToMail\Repositories\Contracts\SearchRepositoryInterface;
5
6
class Delete
7
{
8
    /**
9
     * @var string $searchId
10
     */
11
    protected $searchId;
12
13
    /**
14
     * Create a new job instance.
15
     */
16 2
    public function __construct($searchId = null)
17
    {
18 2
        $this->searchId = $searchId;
19 2
    }
20
21
    /**
22
     * Unsubscribe from a search by deleting it.
23
     *
24
     * @param SearchRepositoryInterface $users
0 ignored issues
show
Bug introduced by
There is no parameter named $users. 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...
25
     *
26
     * @return FlashMessage
27
     */
28 2
    public function handle(SearchRepositoryInterface $searches)
29
    {
30 2
        if ($searches->delete($this->searchId)) {
31 1
            return new FlashMessage(
32 1
                'alert-success',
33 1
                'You will no longer receive emails for this search.'
34
            );
35
        }
36 1
        return new FlashMessage(
37 1
            'alert-danger',
38 1
            'We couldn\'t unsubscribe you. Please try again later or contact us.'
39
        );
40
    }
41
}
42