Test Failed
Push — master ( dbe410...b8c007 )
by Kirill
02:19
created

InputUnionDefinition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 29
loc 29
ccs 2
cts 6
cp 0.3333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 4 4 1
A withDefinition() 8 8 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\AbstractTypeDefinition;
13
use Railt\Reflection\Contracts\Definition\Behaviour\ProvidesTypeDefinitions;
14
use Railt\Reflection\Contracts\Definition\InputUnionDefinition as InputUnionDefinitionInterface;
15
use Railt\Reflection\Contracts\Definition\TypeDefinition;
16
use Railt\Reflection\Contracts\Type as TypeInterface;
17
use Railt\Reflection\Definition\Behaviour\HasDefinitions;
18
use Railt\Reflection\Type;
19
20
/**
21
 * Class InputUnionDefinition
22
 */
23 View Code Duplication
class InputUnionDefinition extends AbstractTypeDefinition implements InputUnionDefinitionInterface
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 HasDefinitions {
26
        withDefinition as private __withDefinition;
27
    }
28
29
    /**
30
     * @return TypeInterface
31
     * @throws \Railt\Io\Exception\ExternalFileException
32
     */
33 16
    public static function getType(): TypeInterface
34
    {
35 16
        return Type::of(Type::INPUT_UNION);
36
    }
37
38
    /**
39
     * @param string|TypeDefinition $type
40
     * @return ProvidesTypeDefinitions
41
     * @throws \Railt\Io\Exception\ExternalFileException
42
     */
43
    public function withDefinition($type): ProvidesTypeDefinitions
44
    {
45
        $instance = $this->fetch($type);
46
47
        $this->verifyInputType($instance);
48
49
        return $this->__withDefinition($instance);
50
    }
51
}
52