Parameter   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 137
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 137
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A getValue() 0 13 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 int          getDataValueType()                  Parameter data type.
21
 */
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
     * List of supported fields.
114
     *
115
     * @var array
116
     */
117
    protected $fields = [
118
        'dataValueType' => self::TEXT,
119
        'value' => '',
120
        'arrayValue' => [],
121
        'shouldSkipConvertion' => false,
122
    ];
123
124
    /**
125
     * Sets the input values.
126
     *
127
     * @param mixed     $value          Value.
128
     * @param int       $valueType      Data value type.
129
     */
130 5
    public function __construct($value, $valueType = self::TEXT)
131
    {
132 5
        if (is_object($value) && (method_exists($value, '__toString'))) {
133 1
            $value = $value->__toString();
134
        }
135 5
        parent::__construct([
136 5
            'dataValueType' => $valueType,
137 5
            'value' => $value,
138
        ]);
139 5
    }
140
141
    /**
142
     * Returns data as an associative array.
143
     *
144
     * @return array
145
     */
146 3
    public function getValue()
147
    {
148
        $data = [
149 3
            'DataValueType' => $this->getDataValueType(),
150 3
            'Value' => parent::getValue(),
151
        ];
152 3
        if (is_array($this->getArrayValue()) && !empty($this->getArrayValue())) {
153 1
            $data['ArrayValue'] = $this->getArrayValue();
154
        }
155 3
        if (!empty($this->getShouldSkipConvertion())) {
156 1
            $data['ShouldSkipConvertion'] = true;
157
        }
158 3
        return $data;
159
    }
160
}
161