| Total Complexity | 8 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait FormAttributeTrait |
||
| 13 | { |
||
| 14 | private ?FormModelInterface $formModel = null; |
||
| 15 | private string $attribute = ''; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return static |
||
| 19 | */ |
||
| 20 | final public function attribute(FormModelInterface $formModel, string $attribute): self |
||
| 21 | { |
||
| 22 | $new = clone $this; |
||
| 23 | $new->formModel = $formModel; |
||
| 24 | $new->attribute = $attribute; |
||
| 25 | return $new; |
||
| 26 | } |
||
| 27 | |||
| 28 | final protected function getFormModel(): FormModelInterface |
||
| 29 | { |
||
| 30 | if ($this->formModel === null) { |
||
| 31 | throw new InvalidArgumentException('Form model is not set.'); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $this->formModel; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return bool|float|int|iterable|object|string|Stringable|null |
||
| 39 | */ |
||
| 40 | final protected function getAttributeValue() |
||
| 43 | } |
||
| 44 | |||
| 45 | final protected function getAttributeLabel(): string |
||
| 46 | { |
||
| 47 | return HtmlForm::getAttributeLabel($this->getFormModel(), $this->attribute); |
||
| 48 | } |
||
| 49 | |||
| 50 | final protected function getAttributeHint(): string |
||
| 53 | } |
||
| 54 | |||
| 55 | final protected function getAttributePlaceholder(): ?string |
||
| 56 | { |
||
| 57 | return $this->getFormModel()->getAttributePlaceholder($this->attribute); |
||
| 58 | } |
||
| 59 | |||
| 60 | final protected function getInputId(): string |
||
| 63 | } |
||
| 64 | } |
||
| 65 |