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

TResultBindingGroup   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addToResultBinding() 5 5 1
A issetResultBinding() 4 4 1
A unsetResultBinding() 4 4 1
A getResultBinding() 4 4 1
A setResultBinding() 5 5 1
A isResultBindingGroupOK() 15 15 3

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\IsOKTraits\IsOKToolboxTrait;
6
use AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TResultBindingType;
7
8 View Code Duplication
trait TResultBindingGroup
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...
9
{
10
    //Grouping for result bindings in function mappings
11
    use IsOKToolboxTrait;
12
13
    /**
14
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TResultBindingType[] $resultBinding
15
     */
16
    private $resultBinding = [];
17
18
    /*
19
     * Adds as resultBinding
20
     *
21
     * @return self
22
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TResultBindingType $resultBinding
23
     */
24
    public function addToResultBinding(TResultBindingType $resultBinding)
25
    {
26
        $this->resultBinding[] = $resultBinding;
27
        return $this;
28
    }
29
30
    /**
31
     * isset resultBinding
32
     *
33
     * @param scalar $index
34
     * @return boolean
35
     */
36
    public function issetResultBinding($index)
37
    {
38
        return isset($this->resultBinding[$index]);
39
    }
40
41
    /**
42
     * unset resultBinding
43
     *
44
     * @param scalar $index
45
     * @return void
46
     */
47
    public function unsetResultBinding($index)
48
    {
49
        unset($this->resultBinding[$index]);
50
    }
51
52
    /**
53
     * Gets as resultBinding
54
     *
55
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TResultBindingType[]
56
     */
57
    public function getResultBinding()
58
    {
59
        return $this->resultBinding;
60
    }
61
62
    /**
63
     * Sets a new resultBinding
64
     *
65
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TResultBindingType[] $resultBinding
66
     * @return self
67
     */
68
    public function setResultBinding(array $resultBinding)
69
    {
70
        $this->resultBinding = $resultBinding;
71
        return $this;
72
    }
73
74
    public function isResultBindingGroupOK(&$msg = null)
75
    {
76
        if (!$this->isValidArray(
77
            $this->resultBinding,
78
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType'
79
        )) {
80
            $msg = "Scalar property array not a valid array";
81
            return false;
82
        }
83
        if (!$this->isChildArrayOK($this->resultBinding, $msg)) {
84
            return false;
85
        }
86
87
        return true;
88
    }
89
90
}
91