Completed
Push — master ( fe66cd...3af1a2 )
by Konstantin
02:26
created

LeadService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 6 6 2
A getResponse() 4 4 1
A parseArrayToEntity() 7 7 1
A getLink() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
1 ignored issue
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 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
     * @return mixed
32
     */
33 2
    public function getResponse()
34
    {
35 2
        return $this->response;
36
    }
37
38
    /**
39
     * @param $array
40
     * @return Lead
41
     */
42 2
    public function parseArrayToEntity($array)
43
    {
44 2
        $lead = new Lead();
45 2
        $lead->set($array);
46
47 2
        return $lead;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 3
    protected function getLink()
54
    {
55 3
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/leads';
56
    }
57
58
}