| Total Complexity | 8 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class Label extends Widget |
||
| 13 | { |
||
| 14 | use FormAttributeTrait; |
||
| 15 | |||
| 16 | private bool $setForAttribute = true; |
||
| 17 | |||
| 18 | private ?string $forId = null; |
||
| 19 | private bool $useInputIdAttribute = true; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string|Stringable|null |
||
| 23 | */ |
||
| 24 | private $content = null; |
||
| 25 | |||
| 26 | protected function run(): string |
||
| 27 | { |
||
| 28 | $tag = LabelTag::tag()->content( |
||
| 29 | $this->content ?? $this->getAttributeLabel() |
||
| 30 | ); |
||
| 31 | |||
| 32 | if ( |
||
| 33 | $this->setForAttribute |
||
| 34 | && $this->useInputIdAttribute |
||
| 35 | && $tag->getAttribute('for') === null |
||
|
|
|||
| 36 | ) { |
||
| 37 | $tag = $tag->forId($this->forId ?? $this->getInputId()); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $tag->render(); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function setForAttribute(bool $value): self |
||
| 44 | { |
||
| 45 | $new = clone $this; |
||
| 46 | $new->setForAttribute = $value; |
||
| 47 | return $new; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return static |
||
| 52 | */ |
||
| 53 | public function forId(?string $id): self |
||
| 54 | { |
||
| 55 | $new = clone $this; |
||
| 56 | $new->forId = $id; |
||
| 57 | return $new; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return static |
||
| 62 | */ |
||
| 63 | public function useInputIdAttribute(bool $value): self |
||
| 64 | { |
||
| 65 | $new = clone $this; |
||
| 66 | $new->useInputIdAttribute = $value; |
||
| 67 | return $new; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string|Stringable|null $content |
||
| 72 | * |
||
| 73 | * @return static |
||
| 74 | */ |
||
| 75 | public function content($content): self |
||
| 80 | } |
||
| 81 | } |
||
| 82 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.