| Conditions | 9 |
| Paths | 24 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 9 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | 75 | public function __construct(mixed $value, mixed $label, bool $useTitleAsValue = false) |
|
| 16 | { |
||
| 17 | 75 | if (is_array($label)) { |
|
| 18 | 32 | $this->label = (string)($label[0] ?? null); |
|
| 19 | |||
| 20 | 32 | if (isset($label[1]) && is_array($label[1])) { |
|
| 21 | 31 | $this->attributes = $label[1]; |
|
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | 75 | $this->label ??= (string)$label; |
|
| 26 | |||
| 27 | /** @since 2.4.0 */ |
||
| 28 | 75 | if (is_string($value)) { |
|
| 29 | 31 | $this->value = \trim($value); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** @since 2.4.0 */ |
||
| 33 | 75 | if (is_int($value) && $useTitleAsValue) { |
|
| 34 | 28 | $this->value = $this->label; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** @since 3.4.0 */ |
||
| 38 | 75 | if (is_int($value) && !$useTitleAsValue) { |
|
| 39 | 17 | $this->value = $value; |
|
| 40 | } |
||
| 58 |