Code Duplication    Length = 26-30 lines in 2 locations

src/Display/Filters/Select.php 1 location

@@ 7-32 (lines=26) @@
4
5
use Sco\Admin\Traits\HasSelectOptions;
6
7
class Select extends Filter
8
{
9
    use HasSelectOptions;
10
11
    protected $type = 'select';
12
13
    protected $options;
14
15
    protected $defaultValue = '';
16
17
    public function __construct($name, $title, $options = null)
18
    {
19
        parent::__construct($name, $title);
20
21
        if (! is_null($options)) {
22
            $this->setOptions($options);
23
        }
24
    }
25
26
    public function toArray()
27
    {
28
        return parent::toArray() + [
29
                'options' => $this->getOptions(),
30
            ];
31
    }
32
}
33

src/Form/Elements/Select.php 1 location

@@ 14-43 (lines=30) @@
11
 * @package Sco\Admin\Form\Elements
12
 * @see http://element.eleme.io/#/en-US/component/select
13
 */
14
class Select extends NamedElement
15
{
16
    use HasSelectOptions;
17
18
    protected $type = 'select';
19
20
    protected $cast = 'string';
21
22
    /**
23
     *
24
     * @param string $name
25
     * @param string $title
26
     * @param array|Model $options
27
     */
28
    public function __construct(string $name, string $title, $options = null)
29
    {
30
        parent::__construct($name, $title);
31
32
        if (! is_null($options)) {
33
            $this->setOptions($options);
34
        }
35
    }
36
37
    public function toArray()
38
    {
39
        return parent::toArray() + [
40
                'options' => $this->getOptions(),
41
            ];
42
    }
43
}
44