| Total Complexity | 9 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class FormDataBinder |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Tree of bound targets. |
||
| 11 | */ |
||
| 12 | private array $bindings = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Wired to a Livewire component. |
||
| 16 | */ |
||
| 17 | private $wire = false; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Bind a target to the current instance |
||
| 21 | * |
||
| 22 | * @param mixed $target |
||
| 23 | * @return void |
||
| 24 | */ |
||
| 25 | public function bind($target): void |
||
| 26 | { |
||
| 27 | $this->bindings[] = $target; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Get the latest bound target. |
||
| 32 | * |
||
| 33 | * @return mixed |
||
| 34 | */ |
||
| 35 | public function get() |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Remove the last binding. |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | public function pop(): void |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Returns wether the form is bound to a Livewire model. |
||
| 52 | * |
||
| 53 | * @return boolean |
||
| 54 | */ |
||
| 55 | public function isWired(): bool |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Returns the modifier, if set. |
||
| 62 | * |
||
| 63 | * @return string|null |
||
| 64 | */ |
||
| 65 | public function getWireModifier(): ?string |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Enable Livewire binding with an optional modifier. |
||
| 72 | * |
||
| 73 | * @param string $modifier |
||
| 74 | * @return void |
||
| 75 | */ |
||
| 76 | public function wire($modifier = null): void |
||
| 77 | { |
||
| 78 | $this->wire = $modifier ?: null; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Disable Livewire binding. |
||
| 83 | * |
||
| 84 | * @return void |
||
| 85 | */ |
||
| 86 | public function endWire(): void |
||
| 89 | } |
||
| 90 | } |
||
| 91 |