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

Select::getOptions()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 27
rs 8.5806
cc 4
eloc 19
nc 4
nop 0
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