Entities
4 years ago
Formatter
4 years ago
Group
4 years ago
Options
4 years ago
Value
4 years ago
Entities.php
4 years ago
Formatter.php
4 years ago
Group.php
4 years ago
MetaValuesFactory.php
4 years ago
Option.php
4 years ago
OptionGroup.php
4 years ago
Options.php
4 years ago
Paginated.php
4 years ago
Response.php
4 years ago
Value.php
4 years ago
OptionGroup.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Helper\Select; |
| 4 | |
| 5 | final class OptionGroup { |
| 6 | |
| 7 | /** |
| 8 | * @var string |
| 9 | */ |
| 10 | private $label; |
| 11 | |
| 12 | /** |
| 13 | * @var Option[] |
| 14 | */ |
| 15 | private $options; |
| 16 | |
| 17 | /** |
| 18 | * @param string $label |
| 19 | * @param Option[] $options |
| 20 | */ |
| 21 | public function __construct( $label, array $options = [] ) { |
| 22 | $this->label = $label; |
| 23 | |
| 24 | foreach ( $options as $option ) { |
| 25 | $this->add_option( $option ); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @return string |
| 31 | */ |
| 32 | public function get_label() { |
| 33 | return $this->label; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @return Option[] |
| 38 | */ |
| 39 | public function get_options() { |
| 40 | return $this->options; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @param Option $option |
| 45 | * |
| 46 | * @return $this |
| 47 | */ |
| 48 | protected function add_option( Option $option ) { |
| 49 | $this->options[] = $option; |
| 50 | |
| 51 | return $this; |
| 52 | } |
| 53 | |
| 54 | } |