Passed
Push — master ( 143625...0aa694 )
by Alex
03:46
created

TFunctionReferenceExpressionType::isOK()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait;
8
9
/**
10
 * Class representing TFunctionReferenceExpressionType
11
 *
12
 *
13
 * XSD Type: TFunctionReferenceExpression
14
 */
15 View Code Duplication
class TFunctionReferenceExpressionType extends IsOK
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...
16
{
17
    use IsOKToolboxTrait, TQualifiedNameTrait;
18
    /**
19
     * @property string $function
20
     */
21
    private $function = null;
22
23
    /**
24
     * @property
25
     * \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[]
26
     * $parameter
27
     */
28
    private $parameter = [];
29
30
    /**
31
     * Gets as function
32
     *
33
     * @return string
34
     */
35
    public function getFunction()
36
    {
37
        return $this->function;
38
    }
39
40
    /**
41
     * Sets a new function
42
     *
43
     * @param string $function
44
     * @return self
45
     */
46
    public function setFunction($function)
47
    {
48
        $this->function = $function;
49
        return $this;
50
    }
51
52
    /**
53
     * Adds as parameter
54
     *
55
     * @return self
56
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType
57
     * $parameter
58
     */
59
    public function addToParameter(TFunctionReferenceExpressionType\ParameterAnonymousType $parameter)
60
    {
61
        $this->parameter[] = $parameter;
62
        return $this;
63
    }
64
65
    /**
66
     * isset parameter
67
     *
68
     * @param scalar $index
69
     * @return boolean
70
     */
71
    public function issetParameter($index)
72
    {
73
        return isset($this->parameter[$index]);
74
    }
75
76
    /**
77
     * unset parameter
78
     *
79
     * @param scalar $index
80
     * @return void
81
     */
82
    public function unsetParameter($index)
83
    {
84
        unset($this->parameter[$index]);
85
    }
86
87
    /**
88
     * Gets as parameter
89
     *
90
     * @return
91
     * \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[]
92
     */
93
    public function getParameter()
94
    {
95
        return $this->parameter;
96
    }
97
98
    /**
99
     * Sets a new parameter
100
     *
101
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[]
102
     * $parameter
103
     * @return self
104
     */
105
    public function setParameter(array $parameter)
106
    {
107
        $this->parameter = $parameter;
108
        return $this;
109
    }
110
111
    public function isOK(&$msg = null)
112
    {
113
        if (!$this->isTQualifiedNameValid($this->function)) {
114
            $msg = "Function must be a valid TQualifiedName";
115
            return false;
116
        }
117
        if (!$this->isValidArrayOK(
118
            $this->function,
0 ignored issues
show
Documentation introduced by
$this->function is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
119
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType',
120
            $msg,
121
            1
122
        )) {
123
            return false;
124
        }
125
        return true;
126
    }
127
}
128