Completed
Push — master ( 839e9e...4e091b )
by Costin
03:53
created

Textarea   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 18.18 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 6
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setSpecificAttributes() 0 5 1
A setPlaceholder() 3 6 3
A setRows() 3 6 3

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 SoareCostin\BladeFormComponents\FormElements;
4
5
use SoareCostin\BladeFormComponents\FormElement;
6
7
class Textarea extends FormElement
8
{
9
    /** @var string */
10
    public $placeholder;
11
12
    /** @var int */
13
    public $rows = 5;
14
15
    /** @var array */
16
    public $attributesList = [
17
        'id', 'name', 'placeholder', 'rows', 'class', 'required', 'disabled', 'readonly', 'autocomplete'
18
    ];
19
20
    protected function setSpecificAttributes()
21
    {
22
        $this->setPlaceholder();
23
        $this->setRows();
24
    }
25
26
    protected function setPlaceholder()
27
    {
28 View Code Duplication
        if (isset($this->params['placeholder']) && !empty($this->params['placeholder'])) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across 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...
29
            $this->placeholder = $this->params['placeholder'];
30
        }
31
    }
32
33
    protected function setRows()
34
    {
35 View Code Duplication
        if (isset($this->params['rows']) && !empty($this->params['rows'])) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across 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...
36
            $this->rows = $this->params['rows'];
37
        }
38
    }
39
}