| Total Complexity | 9 |
| Total Lines | 96 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class FieldView implements ViewInterface |
||
| 12 | { |
||
| 13 | use OptionsTrait; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var ListField |
||
| 17 | */ |
||
| 18 | private $listField; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var RowView |
||
| 22 | */ |
||
| 23 | private $rowView; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var mixed |
||
| 27 | */ |
||
| 28 | private $value; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * FieldView constructor. |
||
| 32 | * |
||
| 33 | * @param ListField $listField |
||
| 34 | */ |
||
| 35 | 9 | public function __construct(ListField $listField) |
|
| 36 | { |
||
| 37 | 9 | $this->listField = $listField; |
|
| 38 | 9 | $this->initOptions($listField->getOption(ListField::OPTION_VIEW_OPTIONS, [])); |
|
|
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return RowView |
||
| 43 | */ |
||
| 44 | 2 | public function getRow(): RowView |
|
| 45 | { |
||
| 46 | 2 | return $this->rowView; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | 1 | public function getId(): string |
|
| 53 | { |
||
| 54 | 1 | return $this->listField->getId(); |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | 2 | public function getValue() |
|
| 61 | { |
||
| 62 | 2 | return $this->value; |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return bool |
||
| 67 | */ |
||
| 68 | 1 | public function isSortable(): bool |
|
| 69 | { |
||
| 70 | 1 | return $this->listField->getOption(ListField::OPTION_SORTABLE); |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return string|null DESC|ASC |
||
| 75 | */ |
||
| 76 | 1 | public function getSort(): ?string |
|
| 77 | { |
||
| 78 | 1 | return $this->listField->getOption(ListField::OPTION_SORT_VALUE); |
|
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | 1 | public function getLabel(): string |
|
| 85 | { |
||
| 86 | 1 | return $this->listField->getOption(ListField::OPTION_LABEL); |
|
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @internal |
||
| 91 | * @return ListField |
||
| 92 | */ |
||
| 93 | 2 | public function getListField(): ListField |
|
| 94 | { |
||
| 95 | 2 | return $this->listField; |
|
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @internal |
||
| 100 | * @param RowView $rowView |
||
| 101 | * @param mixed $value |
||
| 102 | */ |
||
| 103 | 4 | public function init(RowView $rowView, $value): void |
|
| 107 | } |
||
| 108 | } |
||
| 109 |