Passed
Push — master ( 5445ae...d3b8b6 )
by Alex
07:04
created

EndAnonymousType   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 115
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 12
c 0
b 0
f 0
lcom 1
cbo 3
dl 23
loc 115
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getRole() 0 4 1
A setRole() 0 5 1
A getEntitySet() 0 4 1
A setEntitySet() 0 5 1
A getDocumentation() 0 4 1
A setDocumentation() 0 5 1
B isOK() 23 23 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\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\GEmptyElementExtensibilityTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType;
9
10
/**
11
 * Class representing EndAnonymousType
12
 */
13
class EndAnonymousType extends IsOK
14
{
15
    /**
16
     * 1. The number of Ends has to match with ones defined in AssociationType
17
     * 2. Value for attribute Name should match the defined ones and EntitySet should be of the
18
     * defined Entity Type in AssociationType
19
     */
20
21
    use GEmptyElementExtensibilityTrait, TSimpleIdentifierTrait;
22
23
    /**
24
     * @property string $role
25
     */
26
    private $role = null;
27
28
    /**
29
     * @property string $entitySet
30
     */
31
    private $entitySet = null;
32
33
    /**
34
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
35
     */
36
    private $documentation = null;
37
38
    /**
39
     * Gets as role
40
     *
41
     * @return string
42
     */
43
    public function getRole()
44
    {
45
        return $this->role;
46
    }
47
48
    /**
49
     * Sets a new role
50
     *
51
     * @param string $role
52
     * @return self
53
     */
54
    public function setRole($role)
55
    {
56
        $this->role = $role;
57
        return $this;
58
    }
59
60
    /**
61
     * Gets as entitySet
62
     *
63
     * @return string
64
     */
65
    public function getEntitySet()
66
    {
67
        return $this->entitySet;
68
    }
69
70
    /**
71
     * Sets a new entitySet
72
     *
73
     * @param string $entitySet
74
     * @return self
75
     */
76
    public function setEntitySet($entitySet)
77
    {
78
        $this->entitySet = $entitySet;
79
        return $this;
80
    }
81
82
    /**
83
     * Gets as documentation
84
     *
85
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
86
     */
87
    public function getDocumentation()
88
    {
89
        return $this->documentation;
90
    }
91
92
    /**
93
     * Sets a new documentation
94
     *
95
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
96
     * @return self
97
     */
98
    public function setDocumentation(TDocumentationType $documentation)
99
    {
100
        $this->documentation = $documentation;
101
        return $this;
102
    }
103
104 View Code Duplication
    public function isOK(&$msg = null)
0 ignored issues
show
Duplication introduced by
This method 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...
105
    {
106
        if (null != $this->role && !$this->isTSimpleIdentifierValid($this->role)) {
107
            $msg = "Role must be a valid TSimpleIdentifier";
108
            return false;
109
        }
110
        if (!$this->isTSimpleIdentifierValid($this->entitySet)) {
111
            $msg = "Entity set must be a valid TSimpleIdentifier";
112
            return false;
113
        }
114
        if (!$this->isObjectNullOrType(
115
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType',
116
            $this->documentation,
117
            $msg
118
        )) {
119
            return false;
120
        }
121
        if (!$this->isExtensibilityElementOK($msg)) {
122
            return false;
123
        }
124
125
        return true;
126
    }
127
}
128