ContactService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
4
namespace Dolibarr\Client\Service;
5
6
use Dolibarr\Client\Domain\Contact\Contact;
7
use Dolibarr\Client\Domain\Contact\ContactId;
8
use Dolibarr\Client\Domain\Resource\ApiResource;
9
use Dolibarr\Client\Domain\Resource\ResourceId;
10
use Dolibarr\Client\Exception\ApiException;
11
use Dolibarr\Client\HttpClient\HttpClientInterface;
12
use JMS\Serializer\SerializerInterface;
13
14
final class ContactService extends AbstractService
15
{
16
17
    /**
18
     * @param HttpClientInterface $httpClient
19
     * @param SerializerInterface $serializerInterface
20
     */
21
    public function __construct(HttpClientInterface $httpClient, SerializerInterface $serializerInterface)
22
    {
23
        parent::__construct($httpClient, $serializerInterface, new ApiResource('contacts'));
24
    }
25
26
    /**
27
     * @param Contact $contact
28
     *
29
     * @return ContactId
30
     *
31
     * @throws ApiException
32
     */
33
    public function create(Contact $contact)
34
    {
35
        return new ContactId((int)$this->post($this->serialize($contact)));
36
    }
37
}
38