Completed
Push — master ( 1565b3...a35685 )
by Konstantin
03:55 queued 01:55
created

FieldService::parseArrayToEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace linkprofit\AmoCRM\services;
4
5
use linkprofit\AmoCRM\entities\EntityInterface;
6
use linkprofit\AmoCRM\entities\Field;
7
use linkprofit\AmoCRM\RequestHandler;
8
9
/**
10
 * Class FieldService
11
 * @package linkprofit\AmoCRM\services
12
 */
13
class FieldService extends BaseService
14
{
15
    /**
16
     * @var array Field
17
     */
18
    protected $entities = [];
19
20
    /**
21
     * @param Field $field
22
     */
23 2
    public function add(EntityInterface $field)
24
    {
25 2
        if ($field instanceof Field) {
26 2
            $this->entities[] = $field;
27 2
        }
28 2
    }
29
30
    /**
31
     * @param $array
32
     * @return Field
33
     */
34 2
    public function parseArrayToEntity($array)
35
    {
36 2
        $field = new Field();
37 2
        $field->set($array);
38
39 2
        return $field;
40
    }
41
42
    /**
43
     * @return string
44
     */
45 2
    protected function getLink()
46
    {
47 2
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/fields';
48
    }
49
50
}