Code Duplication    Length = 37-46 lines in 2 locations

src/services/ContactService.php 1 location

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

src/services/LeadService.php 1 location

@@ 13-58 (lines=46) @@
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
    public function add(EntityInterface $lead)
24
    {
25
        if ($lead instanceof Lead) {
26
            $this->entities[] = $lead;
27
        }
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33
    public function getResponse()
34
    {
35
        return $this->response;
36
    }
37
38
    /**
39
     * @param $array
40
     * @return Lead
41
     */
42
    public function parseArrayToEntity($array)
43
    {
44
        $lead = new Lead();
45
        $lead->set($array);
46
47
        return $lead;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    protected function getLink()
54
    {
55
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/leads';
56
    }
57
58
}