Attribute   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
wmc 11
eloc 19
dl 0
loc 37
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A isValid() 0 2 4
A setValue() 0 2 1
A getValue() 0 13 5
1
<?php
2
namespace execut\import\components\parser;
3
4
5
use execut\import\components\parser\exception\ColumnIsEmpty;
6
use yii\base\Component;
7
8
class Attribute extends Component
9
{
10
    public $row = null;
11
    public $key = null;
12
    public $column = null;
13
    public $numberDelimiter = null;
14
    public $isRequired = true;
15
    public $isForSearchQuery = true;
16
    protected $value = null;
17 10
    public function getValue() {
18 10
        if ($this->value !== null) {
19 5
            return $this->value;
20
        }
21
22 5
        if (!empty($this->row[$this->column])) {
23 3
            $value = trim($this->row[$this->column]);
24 3
            if ($this->numberDelimiter !== null) {
25 1
                $value = str_replace($this->numberDelimiter, '.', $value);
26
            }
27
28 3
            if ($value) {
29 2
                return $value;
30
            }
31
        }
32 3
    }
33
34
    public function isValid() {
35
        return empty($this->getValue()) && !$this->isRequired || !empty($this->getValue()) && $this->isRequired;
36
    }
37
38 6
    public function setValue($value) {
39 6
        $this->value = $value;
40 6
    }
41
42
    public function __toString()
43
    {
44
        return (string) $this->getValue();
45
    }
46
}