Test Setup Failed
Push — master ( 0a3e88...820bc9 )
by Christopher
04:41
created

ResourcePrimitiveType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 95.45 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 21
loc 22
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 2

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
namespace POData\Providers\Metadata;
4
5
use POData\Providers\Metadata\Type\IType;
6
7 View Code Duplication
class ResourcePrimitiveType extends ResourceType
8
{
9
    /**
10
     * Create new instance of ResourcePrimitiveType.
11
     * @param IType                 $primitive      Instance type for the primitive type
12
     *
13
     * @throws \InvalidArgumentException
14
     */
15
    public function __construct(IType $primitive)
16
    {
17
        $resourceTypeKind = ResourceTypeKind::PRIMITIVE;
18
        $bitz = explode('.', $primitive->getName());
19
        $name = array_pop($bitz);
20
        $namespaceName = null;
21
        if (0 < count($bitz)) {
22
            $namespaceName = implode('.', $bitz);
23
        }
24
        $baseType = null;
25
        $isAbstract = false;
26
        parent::__construct($primitive, $resourceTypeKind, $name, $namespaceName, $baseType, $isAbstract);
27
    }
28
}
29