Completed
Pull Request — master (#33)
by Karl
02:24
created

Delete   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 13 2
1
<?php namespace JobApis\JobsToMail\Jobs\Users;
2
3
use JobApis\JobsToMail\Http\Messages\FlashMessage;
4
use JobApis\JobsToMail\Repositories\Contracts\UserRepositoryInterface;
5
6
class Delete
7
{
8
    /**
9
     * @var string $userId
10
     */
11
    protected $userId;
12
13
    /**
14
     * Create a new job instance.
15
     */
16 2
    public function __construct($userId = null)
17
    {
18 2
        $this->userId = $userId;
19 2
    }
20
21
    /**
22
     * Unsubscribe a user's by deleting their account
23
     *
24
     * @param UserRepositoryInterface $users
25
     *
26
     * @return FlashMessage
27
     */
28 2
    public function handle(UserRepositoryInterface $users)
29
    {
30 2
        if ($users->delete($this->userId)) {
31 1
            return new FlashMessage(
32 1
                'alert-success',
33 1
                'Your account has been cancelled. You will no longer receive any emails from us.'
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