Completed
Branch master (856cc5)
by Mihail
07:21 queued 04:29
created

TextareaField   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 1
cbo 1
dl 41
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A make() 15 15 4

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
namespace Ffcms\Core\Helper\HTML\Form;
3
4
use Ffcms\Core\Helper\HTML\System\NativeGenerator;
5
6 View Code Duplication
class TextareaField extends NativeGenerator implements iField
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...
7
{
8
    private $properties;
9
    private $name;
10
    private $value;
11
    
12
    /**
13
     * TextField constructor. Pass attributes inside model.
14
     * @param array $properties
15
     * @param string $name
16
     * @param string|null $value
17
     */
18
    public function __construct($properties, $name, $value = null)
19
    {
20
        $this->properties = $properties;
21
        $this->name = $name;
22
        $this->value = $value;
23
    }
24
    
25
26
    /**
27
     * Build <input type="text" value="$value" {$properties} /> response
28
     * {@inheritDoc}
29
     * @see \Ffcms\Core\Helper\HTML\Form\iField::make()
30
     */
31
    public function make()
32
    {
33
        // check is html enabled there
34
        $html = false;
35
        if (isset($this->properties['html']) && $this->properties['html'] === true) {
36
            $html = true;
37
            unset($this->properties['html']);
38
        }
39
        // unset value
40
        if (isset($this->properties['value'])) {
41
            unset($this->properties['value']);
42
        }
43
        // return compiled DOM html
44
        return self::buildContainerTag('textarea', $this->properties, $this->value, $html);
45
    }
46
}