| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\ValueObjects\Field; |
| 4 |
|
| 5 |
// phpcs:disable PSR1.Files.SideEffects |
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Class FieldOptions |
| 12 |
* |
| 13 |
* Encapsulates options for a field. |
| 14 |
*/ |
| 15 |
final class FieldOptions |
| 16 |
{ |
| 17 |
/** |
| 18 |
* @var array<int, array<string, int|string|bool>> |
| 19 |
*/ |
| 20 |
private array $options; |
| 21 |
|
| 22 |
/** |
| 23 |
* FieldOptions constructor. |
| 24 |
* |
| 25 |
* @param array<int, array<string, int|string|bool>> $options |
| 26 |
*/ |
| 27 |
public function __construct(array $options) |
| 28 |
{ |
| 29 |
$this->options = $options; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Get the options array. |
| 34 |
* |
| 35 |
* @return array<int, array<string, int|string|bool>> |
| 36 |
*/ |
| 37 |
public function getOptions(): array |
| 38 |
{ |
| 39 |
return $this->options; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Convert the field options to an array. |
| 44 |
* |
| 45 |
* @return array<int, array<string, int|string|bool>> |
| 46 |
*/ |
| 47 |
public function toArray(): array |
| 48 |
{ |
| 49 |
return $this->options; |
| 50 |
} |
| 51 |
} |
| 52 |
|