Passed
Push — master ( 26efa5...f69765 )
by Alex
03:20
created

TIncludeType   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 82
Duplicated Lines 12.2 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
c 0
b 0
f 0
lcom 1
cbo 1
dl 10
loc 82
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getNamespace() 0 4 1
A setNamespace() 0 5 1
A getAlias() 0 4 1
A setAlias() 0 5 1
B isOK() 10 24 6

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 AlgoWeb\ODataMetadata\MetadataV4\edmx;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
7
/**
8
 * Class representing TIncludeType
9
 *
10
 *
11
 * XSD Type: TInclude
12
 */
13
class TIncludeType extends IsOK
14
{
15
16
    /**
17
     * @property string $namespace
18
     */
19
    private $namespace = null;
20
21
    /**
22
     * @property string $alias
23
     */
24
    private $alias = null;
25
26
    /**
27
     * Gets as namespace
28
     *
29
     * @return string
30
     */
31
    public function getNamespace()
32
    {
33
        return $this->namespace;
34
    }
35
36
    /**
37
     * Sets a new namespace
38
     *
39
     * @param string $namespace
40
     * @return self
41
     */
42
    public function setNamespace($namespace)
43
    {
44
        $this->namespace = $namespace;
45
        return $this;
46
    }
47
48
    /**
49
     * Gets as alias
50
     *
51
     * @return string
52
     */
53
    public function getAlias()
54
    {
55
        return $this->alias;
56
    }
57
58
    /**
59
     * Sets a new alias
60
     *
61
     * @param string $alias
62
     * @return self
63
     */
64
    public function setAlias($alias)
65
    {
66
        $this->alias = $alias;
67
        return $this;
68
    }
69
70
    protected function isOK(&$msg = null)
71
    {
72
        if (!$this->isStringNotNullOrEmpty($this->namespace)) {
73
            $msg = "Namespace Must be defined";
74
            return false;
75
        }
76
        if (!$this->isTNamespaceNameValid($this->namespace)) {
0 ignored issues
show
Bug introduced by
The method isTNamespaceNameValid() does not seem to exist on object<AlgoWeb\ODataMeta...taV4\edmx\TIncludeType>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
            $msg = "Namespace Must be a valid NameSpace";
78
            return false;
79
        }
80
81
82 View Code Duplication
        if (null != $this->alias) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
83
            if (!is_string($this->alias)) {
84
                $msg = "Alias must be either a string or null";
85
                return false;
86
            }
87
            if (!$this->isTSimpleIdentifierValid($this->alias)) {
0 ignored issues
show
Bug introduced by
The method isTSimpleIdentifierValid() does not seem to exist on object<AlgoWeb\ODataMeta...taV4\edmx\TIncludeType>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
                $msg = "Alias must be a valid TSimpleIdentifier";
89
                return false;
90
            }
91
        }
92
        return true;
93
    }
94
}
95