Completed
Pull Request — master (#280)
by
unknown
03:35
created

MaskedField::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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\Gui\Ui\Factory;
8
use FML\Types\Renderable;
9
10
/**
11
 * Class TextField
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2018 eXpansion
15
 * @package eXpansion\Framework\Config\Ui
16
 */
17 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...
18
{
19
    /** @var Factory */
20
    protected $uiFactory;
21
22
    /**
23
     * TextField constructor.
24
     *
25
     * @param Factory $uiFactory
26
     */
27
    public function __construct(Factory $uiFactory)
28
    {
29
        $this->uiFactory = $uiFactory;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function build(ConfigInterface $config, $width): Renderable
36
    {
37
        return $this
38
            ->uiFactory
39
            ->createInputMasked($config->getPath(), $config->getRawValue())
40
            ->setWidth($width);
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function isCompatible(ConfigInterface $config): bool
47
    {
48
         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...
49
    }
50
}
51