Completed
Pull Request — master (#294)
by De Cramer
03:48
created

TextAreaField   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 46
loc 46
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A build() 6 6 1
A isCompatible() 4 4 1
A getRawValueFromEntry() 4 4 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 eXpansion\Framework\Config\Ui\Fields;
4
5
use eXpansion\Framework\Config\Model\ConfigInterface;
6
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
7
use eXpansion\Framework\Core\Plugins\Gui\ManialinkFactory;
8
use eXpansion\Framework\Gui\Ui\Factory;
9
use FML\Types\Renderable;
10
11
/**
12
 * Class TextAreaField
13
 *
14
 * @author    reaby
15
 * @copyright 2018 eXpansion
16
 * @package eXpansion\Framework\Config\Ui
17
 */
18 View Code Duplication
class TextAreaField implements UiInterface
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...
19
{
20
    /** @var Factory */
21
    protected $uiFactory;
22
23
    /**
24
     * TextField constructor.
25
     *
26
     * @param Factory $uiFactory
27
     */
28
    public function __construct(Factory $uiFactory)
29
    {
30
        $this->uiFactory = $uiFactory;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function build(ConfigInterface $config, $width, ManialinkInterface $manialink, ManialinkFactory $manialinkFactory): Renderable
37
    {
38
        return $this
39
            ->uiFactory
40
            ->createTextbox($config->getPath(), $config->getRawValue(), 5, $width);
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function isCompatible(ConfigInterface $config): bool
47
    {
48
        return ($config instanceof TextAreaField);
49
    }
50
51
    /**
52
     * Get raw value to set from gui entry data.
53
     *
54
     * @param ConfigInterface $config
55
     * @param                 $entry
56
     *
57
     * @return mixed
58
     */
59
    public function getRawValueFromEntry(ConfigInterface $config, $entry)
60
    {
61
        return $entry;
62
    }
63
}
64