Completed
Push — master ( 3af1a2...bdc52c )
by Konstantin
02:15
created

LeadService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 2
cbo 3
dl 0
loc 38
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 2
A parseArrayToEntity() 0 7 1
A getLink() 0 4 1
1
<?php
2
3
namespace linkprofit\AmoCRM\services;
4
5
use linkprofit\AmoCRM\entities\EntityInterface;
6
use linkprofit\AmoCRM\entities\Lead;
7
use linkprofit\AmoCRM\RequestHandler;
8
9
/**
10
 * Class LeadService
11
 * @package linkprofit\AmoCRM\services
12
 */
13
class LeadService extends BaseService
14
{
15
    /**
16
     * @var array Lead
17
     */
18
    protected $entities = [];
19
20
    /**
21
     * @param Lead $lead
22
     */
23 3
    public function add(EntityInterface $lead)
24
    {
25 3
        if ($lead instanceof Lead) {
26 3
            $this->entities[] = $lead;
27
        }
28 3
    }
29
30
    /**
31
     * @param $array
32
     * @return Lead
33
     */
34 2
    public function parseArrayToEntity($array)
35
    {
36 2
        $lead = new Lead();
37 2
        $lead->set($array);
38
39 2
        return $lead;
40
    }
41
42
    /**
43
     * @return string
44
     */
45 3
    protected function getLink()
46
    {
47 3
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/leads';
48
    }
49
50
}