Passed
Pull Request — master (#2)
by nicolas
03:15
created

ContactListCreator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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