ContactListUnsubscriber::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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