1 | <?php |
||||
2 | |||||
3 | namespace ArgentCrusade\Forms\Traits; |
||||
4 | |||||
5 | use ArgentCrusade\Forms\FormField; |
||||
6 | |||||
7 | trait OptionsTrait |
||||
8 | { |
||||
9 | /** |
||||
10 | * OptionsTrait constructor. |
||||
11 | * |
||||
12 | * @param string $label |
||||
13 | * @param array $options |
||||
14 | */ |
||||
15 | public function __construct(string $label, array $options = []) |
||||
16 | { |
||||
17 | parent::__construct($label); |
||||
18 | |||||
19 | $this->withOptions($options); |
||||
20 | } |
||||
21 | |||||
22 | /** |
||||
23 | * Set options list. |
||||
24 | * |
||||
25 | * @param array $options |
||||
26 | * |
||||
27 | * @return FormField |
||||
28 | */ |
||||
29 | public function withOptions(array $options) |
||||
30 | { |
||||
31 | return $this->withParameter('options', $options); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
32 | } |
||||
33 | |||||
34 | /** |
||||
35 | * Get options list. |
||||
36 | * |
||||
37 | * @return array |
||||
38 | */ |
||||
39 | public function options() |
||||
40 | { |
||||
41 | return $this->getParameter('options', []); |
||||
0 ignored issues
–
show
It seems like
getParameter() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
42 | } |
||||
43 | } |
||||
44 |