ContactListUnsubscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A unsubscribe() 0 8 1
1
<?php
2
3
namespace Dekalee\MailjetBundle\Manager;
4
5
use Dekalee\MailjetBundle\Convertor\ContactListConvertor;
6
use Mailjet\Client;
7
use Mailjet\Resources;
8
9
/**
10
 * Class ContactListUnsubscriber
11
 */
12
class ContactListUnsubscriber
13
{
14
    protected $client;
15
    protected $convertor;
16
17
    /**
18
     * @param ContactListConvertor $convertor
19
     * @param Client               $client
20
     */
21 2
    public function __construct(ContactListConvertor $convertor, Client $client)
22
    {
23 2
        $this->client = $client;
24 2
        $this-> convertor = $convertor;
25 2
    }
26
27
    /**
28
     * @param string $listName
29
     * @param string $contact
30
     */
31 1
    public function unsubscribe($listName, $contact)
32
    {
33 1
        $contactListId = $this->convertor->convert($listName);
34 1
        $this->client->post(Resources::$ContactslistManagecontact, ['id' => $contactListId, 'body' => [
35 1
            'Action' => 'unsub',
36 1
            'Email' => $contact,
37 1
        ]]);
38 1
    }
39
}
40