FieldsMergeable   A
last analyzed

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
namespace linkprofit\AmoCRM\traits;
4
5
/**
6
 * Class FieldsMergeable
7
 * @package linkprofit\AmoCRM\traits
8
 */
9
trait FieldsMergeable
10
{
11
    /**
12
     * @param $fieldName
13
     * @param $string
14
     */
15 8
    public function mergeStringToField($string, $fieldName)
16
    {
17 8
        $string = (string) $string;
18 8
        $fieldIsSet = mb_strlen($this->$fieldName) > 0 && !is_array($this->$fieldName);
19
20 8
        if (!$fieldIsSet) {
21 8
            $this->$fieldName = $string;
22 8
        } else {
23 6
            $this->$fieldName .= ',' . $string;
24
        }
25
    }
26
}