Total Complexity | 9 |
Total Lines | 125 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class Select2 extends Select implements FormFieldInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $width; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $theme = 'default'; |
||
19 | |||
20 | /** |
||
21 | * |
||
22 | */ |
||
23 | protected $config = []; |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | */ |
||
28 | public const EXPECTED_CLASS = 'saveyour--select2'; |
||
29 | |||
30 | /** |
||
31 | * |
||
32 | */ |
||
33 | public const EXPECTED_DATA_KEY = 'data-saveyour__select2'; |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | */ |
||
38 | public function __construct(array $config = []) |
||
39 | { |
||
40 | $this->config = $config + $this->config; |
||
41 | |||
42 | parent::__construct(); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Get the value of config |
||
47 | * |
||
48 | * @return mixed |
||
49 | */ |
||
50 | public function getConfig() |
||
51 | { |
||
52 | return $this->config; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Get the value of width |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function getWidth(): string |
||
61 | { |
||
62 | return $this->width; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Set the value of width |
||
67 | * |
||
68 | * @param string $width |
||
69 | * |
||
70 | * @return self |
||
71 | */ |
||
72 | public function setWidth(string $width) |
||
73 | { |
||
74 | $this->width = $width; |
||
75 | |||
76 | return $this; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Get the value of theme |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getTheme(): string |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Set the value of theme |
||
91 | * |
||
92 | * @param string $theme |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | public function setTheme(string $theme) |
||
97 | { |
||
98 | $this->theme = $theme; |
||
99 | |||
100 | return $this; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * |
||
105 | */ |
||
106 | protected function resolveAttributes(): AbstractHtmlElement |
||
107 | { |
||
108 | $this->addClass(static::EXPECTED_CLASS); |
||
109 | |||
110 | return parent::resolveAttributes() |
||
111 | ->addAttribute(static::EXPECTED_DATA_KEY, $this->getConfiguration()); |
||
|
|||
112 | } |
||
113 | |||
114 | /** |
||
115 | * |
||
116 | */ |
||
117 | protected function getConfiguration(): string |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * |
||
124 | */ |
||
125 | protected function resolveConfiguration(): array |
||
133 | ]; |
||
134 | } |
||
135 | } |
||
136 |