Completed
Push — master ( 10405b...259f27 )
by wen
13:10
created

Select::setOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Sco\Admin\Traits\HasSelectOptions;
7
8 View Code Duplication
class Select extends NamedElement
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    use HasSelectOptions;
11
12
    protected $type = 'select';
13
14
    protected $cast = 'string';
15
16
17
    /**
18
     *
19
     * @param string $name
20
     * @param string $title
21
     * @param array|Model $options
22
     */
23
    public function __construct(string $name, string $title, $options = null)
24
    {
25
        parent::__construct($name, $title);
26
27
        if (! is_null($options)) {
28
            $this->setOptions($options);
29
        }
30
    }
31
32
    public function toArray()
33
    {
34
        return parent::toArray() + [
35
                'options' => $this->getOptions(),
36
            ];
37
    }
38
}
39