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

ContactListCreator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 1
cbo 2
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A addContactToList() 0 6 1
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