RemoveMailchimpMember::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php namespace DiegoCaprioli\Larachimp\Jobs;
2
3
use DiegoCaprioli\Larachimp\Models\LarachimpListMember;
4
use DiegoCaprioli\Larachimp\Services\MailchimpManager;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Queue\InteractsWithQueue;
8
use Illuminate\Queue\SerializesModels;
9
use Illuminate\Support\Facades\App;
10
11
/**
12
 * Removes a member from the Mailchip list
13
 */
14 View Code Duplication
class RemoveMailchimpMember implements SelfHandling, ShouldQueue
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    use InteractsWithQueue, SerializesModels;
17
18
    /**
19
     * The old email that needs to be replaced with the new one on the member
20
     * 
21
     * @var string
22
     */
23
    private $email;
24
25
    /**
26
     * Create a new job instance.
27
     * 
28
     * @param string $email
29
     */
30 2
    public function __construct($email)
31
    {        
32 2
        $this->email = $email;
33 2
    }
34
35
    /**
36
     * Execute the job.
37
     */
38 2
    public function handle()
39
    {
40
        // The Job only executes if the apiKey is set! This works sort of an
41
        // on/off switch
42 2
        if (!empty(config('diegocaprioli.larachimp.larachimp.api_key'))) {
43 2
            $manager = App::make(MailchimpManager::class);
44 2
            $manager->removeListMember($this->email);
45 2
        }        
46 2
    }
47
}
48