Completed
Push — master ( d43887...767130 )
by De Cramer
9s
created

MaskedField::getRawValueFromEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Config\Ui\Fields;
4
5
use eXpansion\Framework\Config\Model\ConfigInterface;
6
use eXpansion\Framework\Config\Model\PasswordConfig;
7
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
8
use eXpansion\Framework\Core\Plugins\Gui\ManialinkFactory;
9
use eXpansion\Framework\Gui\Ui\Factory;
10
use FML\Types\Renderable;
11
12
/**
13
 * Class TextField
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2018 eXpansion
17
 * @package eXpansion\Framework\Config\Ui
18
 */
19 View Code Duplication
class MaskedField 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...
20
{
21
    /** @var Factory */
22
    protected $uiFactory;
23
24
    /**
25
     * TextField constructor.
26
     *
27
     * @param Factory $uiFactory
28
     */
29
    public function __construct(Factory $uiFactory)
30
    {
31
        $this->uiFactory = $uiFactory;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function build(ConfigInterface $config, $width, ManialinkInterface $manialink, ManialinkFactory $manialinkFactory): Renderable
38
    {
39
        return $this
40
            ->uiFactory
41
            ->createInputMasked($config->getPath(), $config->getRawValue())
42
            ->setWidth($width);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function isCompatible(ConfigInterface $config): bool
49
    {
50
         return ($config instanceof PasswordConfig);
0 ignored issues
show
Bug introduced by
The class eXpansion\Framework\Config\Model\PasswordConfig does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
51
    }
52
53
    /**
54
     * Get raw value to set from gui entry data.
55
     *
56
     * @param ConfigInterface $config
57
     * @param                 $entry
58
     *
59
     * @return mixed
60
     */
61
    public function getRawValueFromEntry(ConfigInterface $config, $entry)
62
    {
63
        return $entry;
64
    }
65
}
66