Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
IsSelectable
80.00% covered (warning)
80.00%
4 / 5
66.67% covered (warning)
66.67%
2 / 3
4.13
0.00% covered (danger)
0.00%
0 / 1
 add
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 options
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getOptions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field\Capability;
6
7trait IsSelectable
8{
9    /** @var array<string|array<string, mixed>> */
10    protected array $options = [];
11
12    /** @param string|array<string, mixed> $option */
13    public function add(string|array $option): void
14    {
15        $this->options[] = $option;
16    }
17
18    /** @param array<string|array<string, mixed>> $options */
19    public function options(array $options): void
20    {
21        if (is_array($options[0])) {
22            $this->hasLabel = true;
23        }
24
25        $this->options = $options;
26    }
27
28    /** @return array<string|array<string, mixed>> */
29    public function getOptions(): array
30    {
31        return $this->options;
32    }
33}