Completed
Push — master ( 65f7a2...1565b3 )
by Konstantin
07:54 queued 01:51
created

FieldsMergeable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A mergeStringToField() 0 11 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 15.02.18
6
 * Time: 16:11
7
 */
8
9
namespace linkprofit\AmoCRM\traits;
10
11
trait FieldsMergeable
12
{
13
    /**
14
     * @param $fieldName
15
     * @param $string
16
     */
17 8
    public function mergeStringToField($string, $fieldName)
18
    {
19 8
        $string = (string) $string;
20 8
        $fieldIsSet = mb_strlen($this->$fieldName) > 0 && !is_array($this->$fieldName);
21
22 8
        if (!$fieldIsSet) {
23 8
            $this->$fieldName = $string;
24 8
        } else {
25 6
            $this->$fieldName .= ',' . $string;
26
        }
27
    }
28
}