Passed
Push — master ( f3b94d...fdd73f )
by nicolas
01:01
created

ContactListSubscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
ccs 4
cts 4
cp 1
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Dekalee\MailjetBundle\Manager;
4
5
use Dekalee\MailjetBundle\Convertor\ContactListConvertor;
6
use Dekalee\MailjetBundle\Creator\ContactCreator;
7
8
/**
9
 * Class ContactListSubscriber
10
 */
11
class ContactListSubscriber
12
{
13
    protected $contactCreator;
14
    protected $contactListConvertor;
15
16
    /**
17
     * @param ContactListConvertor $contactListConvertor
18
     * @param ContactCreator       $contactCreator
19
     */
20 2
    public function __construct(
21
        ContactListConvertor $contactListConvertor,
22
        ContactCreator $contactCreator
23
    ) {
24 2
        $this->contactCreator = $contactCreator;
25 2
        $this->contactListConvertor = $contactListConvertor;
26 2
    }
27
28
    /**
29
     * @param string $name
30
     * @param string $contact
31
     * @param array  $parameters
32
     *
33
     * @throws \Dekalee\MailjetBundle\Exception\ContactListNotCreated
34
     */
35 1
    public function subscribe($name, $contact, array $parameters = [])
36
    {
37 1
        $contactListId = $this->contactListConvertor->convert($name);
38 1
        $this->contactCreator->create($name, $contact, $parameters);
39 1
        $this->contactCreator->addToList($contactListId, $contact);
40 1
    }
41
}
42