Test Failed
Push — master ( 86235b...91db11 )
by Kirill
02:29
created

ObjectDefinition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 41
loc 41
ccs 3
cts 7
cp 0.4286
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 4 4 1
A instanceOf() 7 7 2
A isRenderable() 4 4 1
A isInputable() 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
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Definition;
11
12
use Railt\Reflection\Contracts\Definition\ObjectDefinition as ObjectDefinitionInterface;
13
use Railt\Reflection\Contracts\Definition\TypeDefinition;
14
use Railt\Reflection\Contracts\TypeInterface;
15
use Railt\Reflection\Definition\Behaviour\HasFields;
16
use Railt\Reflection\Definition\Behaviour\HasInterfaces;
17
use Railt\Reflection\Type;
18
use Railt\Reflection\AbstractTypeDefinition;
19
20
/**
21
 * Class ObjectDefinition
22
 */
23 View Code Duplication
class ObjectDefinition extends AbstractTypeDefinition implements ObjectDefinitionInterface
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...
24
{
25
    use HasInterfaces;
26
    use HasFields;
27
28
    /**
29
     * @return TypeInterface
30
     */
31
    public static function getType(): TypeInterface
32
    {
33
        return Type::of(Type::INTERFACE);
34
    }
35
36
    /**
37
     * @param TypeDefinition $definition
38
     * @return bool
39
     */
40 1
    public function instanceOf($definition): bool
41
    {
42
        // Return a positive response if the parent type (like Object or Interface)
43
        // can implement the desired type.
44 1
        return $this->isImplements($definition) ||
45 1
            parent::instanceOf($definition);
46
    }
47
48
    /**
49
     * @return bool
50
     */
51
    public function isRenderable(): bool
52
    {
53
        return true;
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isInputable(): bool
60
    {
61
        return false;
62
    }
63
}
64