ContactService::add()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace linkprofit\AmoCRM\services;
4
5
use linkprofit\AmoCRM\entities\Contact;
6
use linkprofit\AmoCRM\entities\EntityInterface;
7
8
/**
9
 * Class ContactService
10
 * @package linkprofit\AmoCRM\services
11
 */
12 View Code Duplication
class ContactService extends BaseService
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var Contact[]
16
     */
17
    protected $entities = [];
18
19
    /**
20
     * @param Contact $contact
21
     */
22 4
    public function add(EntityInterface $contact)
23
    {
24 4
        if ($contact instanceof Contact) {
25 4
            $this->entities[] = $contact;
26 4
        }
27 4
    }
28
29
    /**
30
     * @param $array
31
     * @return Contact
32
     */
33 4
    public function parseArrayToEntity($array)
34
    {
35 4
        $contact = new Contact();
36 4
        $contact->set($array);
37
38 4
        return $contact;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 4
    protected function getLink()
45
    {
46 4
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/contacts';
47
    }
48
}