Select   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 30
loc 30
ccs 0
cts 13
cp 0
rs 10
c 5
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 2
A toArray() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Sco\Admin\Traits\HasSelectOptions;
7
8
/**
9
 * Class Select
10
 *
11
 * @package Sco\Admin\Form\Elements
12
 * @see http://element.eleme.io/#/en-US/component/select
13
 */
14 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...
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