| Total Complexity | 11 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 76.47% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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() |
||
| 45 | } |
||
| 46 | } |