Passed
Push — master ( 9c8d3b...04f5d8 )
by Oss
01:40
created

Parameter::getValue()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 0
crap 4
1
<?php
2
/**
3
 * @category    Brownie/BpmOnline
4
 * @author      Brownie <[email protected]>
5
 * @license     https://opensource.org/licenses/MIT
6
 */
7
8
namespace Brownie\BpmOnline\DataService\Column\Expression;
9
10
use Brownie\BpmOnline\DataService\Column\Expression;
11
12
/**
13
 * Specifies the value that will be contained in the added column.
14
 *
15
 * @method []|mixed     getArrayValue()                     Returns an array of column values.
16
 * @method bool         setArrayValue(array $values)        Sets an array of values column.
17
 * @method bool         getShouldSkipConvertion()           Returns the flag to skip the cast process.
18
 * @method Parameter    setShouldSkipConvertion($isSkip)    Sets the flag to skip the cast process.
19
 *                                                          for the Value property.
20
 * @method bool         getDataValueType()                  Parameter data type.
21
 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment []|mixed at position 0 could not be parsed: Unknown type name '[' at position 0 in []|mixed.
Loading history...
22
class Parameter extends Expression
23
{
24
25
    /**
26
     * Guid.
27
     */
28
    const GUID = 0;
29
30
    /**
31
     * Text.
32
     */
33
    const TEXT = 1;
34
35
    /**
36
     * Integer.
37
     */
38
    const INTEGER = 4;
39
40
    /**
41
     * Float.
42
     */
43
    const FLOAT = 5;
44
45
    /**
46
     * Money.
47
     */
48
    const MONEY = 6;
49
50
    /**
51
     * DateTime.
52
     */
53
    const DATE_TIME = 7;
54
55
    /**
56
     * Date.
57
     */
58
    const DATE = 8;
59
60
    /**
61
     * Time.
62
     */
63
    const TIME = 9;
64
65
    /**
66
     * Lookup.
67
     */
68
    const LOOKUP = 10;
69
70
    /**
71
     * Enum.
72
     */
73
    const ENUM = 11;
74
75
    /**
76
     * Boolean.
77
     */
78
    const BOOLEAN = 12;
79
80
    /**
81
     * Blob.
82
     */
83
    const BLOB = 13;
84
85
    /**
86
     * Image.
87
     */
88
    const IMAGE = 14;
89
90
    /**
91
     * ImageLookup.
92
     */
93
    const IMAGE_LOOKUP = 16;
94
95
    /**
96
     * Color.
97
     */
98
    const COLOR = 18;
99
100
    /**
101
     * Mapping.
102
     */
103
    const MAPPING = 26;
104
105
    /**
106
     * Key depending on the ExpressionType property.
107
     *
108
     * @var string
109
     */
110
    protected $keyName = 'Parameter';
111
112
    /**
113
     * Sets the input values.
114
     *
115
     * @param mixed     $value          Value.
116
     * @param int       $valueType      Data value type.
117
     */
118 4
    public function __construct($value, $valueType = self::TEXT)
119
    {
120 4
        parent::__construct([
121 4
            'dataValueType' => $valueType,
122 4
            'value' => $value,
123
        ]);
124 4
    }
125
126
    /**
127
     * List of supported fields.
128
     *
129
     * @var array
130
     */
131
    protected $fields = [
132
        'dataValueType' => self::TEXT,
133
        'value' => '',
134
        'arrayValue' => [],
135
        'shouldSkipConvertion' => false,
136
    ];
137
138
    /**
139
     * Returns data as an associative array.
140
     *
141
     * @return array
142
     */
143 3
    public function getValue()
144
    {
145
        $data = [
146 3
            'DataValueType' => $this->getDataValueType(),
0 ignored issues
show
Bug introduced by
The method getDataValueType() does not exist on Brownie\BpmOnline\DataSe...mn\Expression\Parameter. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

146
            'DataValueType' => $this->/** @scrutinizer ignore-call */ getDataValueType(),
Loading history...
147 3
            'Value' => parent::getValue(),
148
        ];
149 3
        if (!empty($this->getArrayValue()) && is_array($this->getArrayValue())) {
0 ignored issues
show
Bug introduced by
The method getArrayValue() does not exist on Brownie\BpmOnline\DataSe...mn\Expression\Parameter. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        if (!empty($this->/** @scrutinizer ignore-call */ getArrayValue()) && is_array($this->getArrayValue())) {
Loading history...
150 1
            $data['ArrayValue'] = $this->getArrayValue();
151
        }
152 3
        if (!empty($this->getShouldSkipConvertion())) {
0 ignored issues
show
Bug introduced by
The method getShouldSkipConvertion() does not exist on Brownie\BpmOnline\DataSe...mn\Expression\Parameter. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

152
        if (!empty($this->/** @scrutinizer ignore-call */ getShouldSkipConvertion())) {
Loading history...
153 1
            $data['ShouldSkipConvertion'] = true;
154
        }
155 3
        return $data;
156
    }
157
}
158