Completed
Pull Request — master (#397)
by De Cramer
02:34
created

PlayerListField::isCompatible()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace eXpansion\Framework\Config\Ui\Fields;
4
use eXpansion\Framework\Config\Model\ConfigInterface;
5
use eXpansion\Framework\Config\Model\PlayerListConfig;
6
7
/**
8
 * Class PlayerListField
9
 *
10
 * @author    de Cramer Oliver<[email protected]>
11
 * @copyright 2018 Smile
12
 * @package eXpansion\Framework\Config\Ui\Fields
13
 */
14
class PlayerListField extends TextListField
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    protected function getElementName($element)
20
    {
21
        if (!empty($element->getNickName())) {
22
            return "{$element->getNickname()} {$element->getLogin()}";
23
        }
24
25
        return $element->getLogin();
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function isCompatible(ConfigInterface $config): bool
32
    {
33
        return parent::isCompatible($config) && $config instanceof PlayerListConfig;
0 ignored issues
show
Bug introduced by
The class eXpansion\Framework\Config\Model\PlayerListConfig 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...
34
    }
35
}