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