Passed
Push — master ( 4f7966...46bec3 )
by Alex
04:29
created

TPropertyGroup   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 97
Duplicated Lines 13.4 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getComplexProperty() 0 4 1
A setComplexProperty() 0 5 1
A getScalarProperty() 0 4 1
A setScalarProperty() 0 5 1
A getCondition() 0 4 1
A setCondition() 0 5 1
B isPropertyGroupOK() 13 13 7

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\mapping\cs\Groups;
4
5
use AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType;
6
use AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType;
7
use AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType;
8
9
trait TPropertyGroup
10
{
11
    /**
12
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty
13
     */
14
    private $complexProperty = null;
15
16
    /**
17
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty
18
     */
19
    private $scalarProperty = null;
20
21
    /**
22
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition
23
     */
24
    private $condition = null;
25
26
    /**
27
     * Gets as complexProperty
28
     *
29
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType
30
     */
31
    public function getComplexProperty()
32
    {
33
        return $this->complexProperty;
34
    }
35
36
    /**
37
     * Sets a new complexProperty
38
     *
39
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty
40
     * @return self
41
     */
42
    public function setComplexProperty(TComplexPropertyType $complexProperty)
43
    {
44
        $this->complexProperty = $complexProperty;
45
        return $this;
46
    }
47
48
    /**
49
     * Gets as scalarProperty
50
     *
51
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType
52
     */
53
    public function getScalarProperty()
54
    {
55
        return $this->scalarProperty;
56
    }
57
58
    /**
59
     * Sets a new scalarProperty
60
     *
61
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty
62
     * @return self
63
     */
64
    public function setScalarProperty(TScalarPropertyType $scalarProperty)
65
    {
66
        $this->scalarProperty = $scalarProperty;
67
        return $this;
68
    }
69
70
    /**
71
     * Gets as condition
72
     *
73
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType
74
     */
75
    public function getCondition()
76
    {
77
        return $this->condition;
78
    }
79
80
    /**
81
     * Sets a new condition
82
     *
83
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition
84
     * @return self
85
     */
86
    public function setCondition(TConditionType $condition)
87
    {
88
        $this->condition = $condition;
89
        return $this;
90
    }
91
92 View Code Duplication
    public function isPropertyGroupOK(&$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...
93
    {
94
        if (null != $this->scalarProperty && !$this->scalarProperty->isOK($msg)) {
95
            return false;
96
        }
97
        if (null != $this->complexProperty && !$this->complexProperty->isOK($msg)) {
98
            return false;
99
        }
100
        if (null != $this->condition && !$this->condition->isOK($msg)) {
101
            return false;
102
        }
103
        return true;
104
    }
105
}
106