| Total Complexity | 6 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class OptionGroup extends CompositionObject |
||
| 9 | { |
||
| 10 | use OptionsTrait; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Option group label. |
||
| 14 | * |
||
| 15 | * @var Maknz\Slack\BlockElement\Text |
||
|
|
|||
| 16 | */ |
||
| 17 | protected $label; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Internal attribute to property map. |
||
| 21 | * |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | protected static $availableAttributes = [ |
||
| 25 | 'label' => 'label', |
||
| 26 | 'options' => 'options', |
||
| 27 | ]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get the option group label. |
||
| 31 | * |
||
| 32 | * @return Maknz\Slack\BlockElement\Text |
||
| 33 | */ |
||
| 34 | 2 | public function getLabel() |
|
| 35 | { |
||
| 36 | 2 | return $this->label; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Set the option group label. |
||
| 41 | * |
||
| 42 | * @param mixed $label |
||
| 43 | * |
||
| 44 | * @return OptionGroup |
||
| 45 | * |
||
| 46 | * @throws \InvalidArgumentException |
||
| 47 | */ |
||
| 48 | 7 | public function setLabel($label) |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Get whether the option group has a selected option |
||
| 57 | * |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 4 | public function hasSelectedOption() |
|
| 61 | { |
||
| 62 | 4 | foreach ($this->getOptions() as $option) { |
|
| 63 | 4 | if ($option->isInitiallySelected()) { |
|
| 64 | 4 | return true; |
|
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | 3 | return false; |
|
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Convert the block to its array representation. |
||
| 73 | * |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | 2 | public function toArray() |
|
| 84 | } |
||
| 85 | } |
||
| 86 |