Completed
Push — master ( 28f264...c80ec8 )
by Daniel
06:10
created

Salariu::setLabelSuffix()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.2
cc 4
eloc 5
nc 2
nop 1
1
<?php
2
3
/**
4
 *
5
 * The MIT License (MIT)
6
 *
7
 * Copyright (c) 2016 Daniel Popiniuc
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in all
17
 * copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
 * SOFTWARE.
26
 *
27
 */
28
29
namespace danielgp\salariu;
30
31
class Salariu
32
{
33
34
    use \danielgp\bank_holidays\Romanian,
35
        \danielgp\common_lib\CommonCode,
36
        \danielgp\salariu\Bonuses,
37
        \danielgp\salariu\ForeignCurrency,
38
        \danielgp\salariu\Taxation;
39
40
    private $appFlags;
41
    private $tApp = null;
42
43
    public function __construct()
44
    {
45
        $configPath        = 'Salariu' . DIRECTORY_SEPARATOR . 'config';
46
        $interfaceElements = $this->readTypeFromJsonFileUniversal($configPath, 'interfaceElements');
47
        $this->appFlags    = [
48
            'FI'   => $interfaceElements['Form Input'],
49
            'TCAS' => $interfaceElements['Table Cell Applied Style'],
50
            'TCSD' => $interfaceElements['Table Cell Style Definitions'],
51
        ];
52
        $this->initializeSprGlbAndSession();
53
        $this->handleLocalizationSalariu($interfaceElements['Application']);
54
        echo $this->setHeaderHtml();
55
        $this->processFormInputDefaults($interfaceElements['Default Values']);
56
        echo $this->setFormInput();
57
        $this->setExchangeRateValues($interfaceElements['Application'], $interfaceElements['Relevant Currencies']);
58
        echo $this->setFormOutput($configPath);
59
        echo $this->setFooterHtml($interfaceElements['Application']);
60
    }
61
62
    private function buildArrayOfFieldsStyled()
63
    {
64
        $sReturn = [];
65
        foreach ($this->appFlags['TCAS'] as $key => $value) {
66
            $sReturn[$this->tApp->gettext($key)] = $value;
67
        }
68
        return $sReturn;
69
    }
70
71
    private function buildStyleForCellFormat($styleId)
72
    {
73
        $sReturn = [];
74
        foreach ($this->appFlags['TCSD'][$styleId] as $key => $value) {
75
            $sReturn[] = $key . ':' . $value;
76
        }
77
        return implode(';', $sReturn) . ';';
78
    }
79
80
    private function getOvertimes($aryStngs)
81
    {
82
        $pcToBoolean = [0 => true, 1 => false];
83
        $pcBoolean   = $pcToBoolean[$this->tCmnSuperGlobals->get('pc')];
84
        $ymVal       = $this->tCmnSuperGlobals->get('ym');
85
        $snVal       = $this->tCmnSuperGlobals->get('sn');
86
        $mnth        = $this->setMonthlyAverageWorkingHours($ymVal, $aryStngs, $pcBoolean);
87
        return [
88
            'os175' => ceil($this->tCmnSuperGlobals->get('os175') * 1.75 * $snVal / $mnth),
89
            'os200' => ceil($this->tCmnSuperGlobals->get('os200') * 2 * $snVal / $mnth),
90
        ];
91
    }
92
93
    private function getValues($lngBase, $aStngs)
94
    {
95
        $inDate           = $this->tCmnSuperGlobals->get('ym');
96
        $inDT             = new \DateTime(date('Y/m/d', $inDate));
97
        $wkDay            = $this->setWorkingDaysInMonth($inDT, $this->tCmnSuperGlobals->get('pc'));
98
        $nMealDays        = ($wkDay - $this->tCmnSuperGlobals->get('zfb'));
99
        $shLbl            = [
100
            'HFP'  => 'Health Fund Percentage',
101
            'HFUL' => 'Health Fund Upper Limit',
102
            'HTP'  => 'Health Tax Percentage',
103
            'IT'   => 'Income Tax',
104
            'MTV'  => 'Meal Ticket Value',
105
        ];
106
        $unemploymentBase = $lngBase;
107
        if ($this->tCmnSuperGlobals->get('ym') < mktime(0, 0, 0, 1, 1, 2008)) {
108
            $unemploymentBase = $this->tCmnSuperGlobals->get('sn');
109
        }
110
        $aReturn           = [
111
            'ba'       => $this->setFoodTicketsValue($inDate, $aStngs[$shLbl['MTV']]) * $nMealDays,
112
            'cas'      => $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]),
113
            'sanatate' => $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']]),
114
            'somaj'    => $this->setUnemploymentTax($inDate, $unemploymentBase),
115
        ];
116
        $pdVal             = [
117
            $inDate,
118
            ($lngBase + $aReturn['ba']),
119
            $this->tCmnSuperGlobals->get('pi'),
120
            $aStngs['Personal Deduction'],
121
        ];
122
        $aReturn['pd']     = $this->setPersonalDeduction($pdVal[0], $pdVal[1], $pdVal[2], $pdVal[3]);
123
        $restArrayToDeduct = [
124
            $aReturn['cas'],
125
            $aReturn['sanatate'],
126
            $aReturn['somaj'],
127
            $aReturn['pd'],
128
        ];
129
        $rest              = $lngBase - array_sum($restArrayToDeduct);
130
        if ($inDate >= mktime(0, 0, 0, 7, 1, 2010)) {
131
            $rest += round($aReturn['ba'], -4);
132
            if ($inDate >= mktime(0, 0, 0, 10, 1, 2010)) {
133
                $aReturn['gbns'] = $this->tCmnSuperGlobals->get('gbns') * pow(10, 4);
134
                $rest            += round($aReturn['gbns'], -4);
135
            }
136
        }
137
        $rest               += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
138
        $aReturn['impozit'] = $this->setIncomeTax($inDate, $rest, $aStngs[$shLbl['IT']]);
139
        $aReturn['zile']    = $wkDay;
140
        return $aReturn;
141
    }
142
143
    private function handleLocalizationSalariu($appSettings)
144
    {
145
        $this->handleLocalizationSalariuInputsIntoSession($appSettings);
146
        $this->handleLocalizationSalariuSafe($appSettings);
147
        $localizationFile = 'Salariu/locale/' . $this->tCmnSession->get('lang') . '/LC_MESSAGES/salariu.mo';
148
        $translations     = new \Gettext\Translations;
149
        $translations->addFromMoFile($localizationFile);
150
        $this->tApp       = new \Gettext\Translator();
151
        $this->tApp->loadTranslations($translations);
152
    }
153
154
    private function handleLocalizationSalariuInputsIntoSession($appSettings)
155
    {
156
        if (is_null($this->tCmnSuperGlobals->get('lang')) && is_null($this->tCmnSession->get('lang'))) {
157
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
158
        } elseif (!is_null($this->tCmnSuperGlobals->get('lang'))) {
159
            $this->tCmnSession->set('lang', filter_var($this->tCmnSuperGlobals->get('lang'), FILTER_SANITIZE_STRING));
160
        }
161
    }
162
163
    /**
164
     * to avoid potential language injections from other applications that do not applies here
165
     */
166
    private function handleLocalizationSalariuSafe($appSettings)
167
    {
168
        if (!array_key_exists($this->tCmnSession->get('lang'), $appSettings['Available Languages'])) {
169
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
170
        }
171
    }
172
173
    private function processFormInputDefaults($inDefaultValues)
174
    {
175
        if (is_null($this->tCmnSuperGlobals->get('ym'))) {
176
            $this->tCmnSuperGlobals->request->set('ym', mktime(0, 0, 0, date('m'), 1, date('Y')));
177
        }
178
        foreach ($inDefaultValues as $key => $value) {
179
            if (is_null($this->tCmnSuperGlobals->get($key))) {
180
                $this->tCmnSuperGlobals->request->set($key, $value);
181
            }
182
        }
183
    }
184
185
    private function setFooterHtml($appSettings)
186
    {
187
        $sReturn = $this->setUpperRightBoxLanguages($appSettings['Available Languages'])
188
            . '<div class="resetOnly author">&copy; ' . date('Y') . ' '
189
            . $appSettings['Copyright Holder'] . '</div>'
190
            . '<hr/>'
191
            . '<div class="disclaimer">'
192
            . $this->tApp->gettext('i18n_Disclaimer')
193
            . '</div>';
194
        return $this->setFooterCommon($sReturn);
0 ignored issues
show
Documentation introduced by
$sReturn is of type string, but the function expects a array|null.

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...
195
    }
196
197
    private function setFormInput()
198
    {
199
        $sReturn     = $this->setFormInputElements();
200
        $btn         = $this->setStringIntoShortTag('input', [
201
            'type'  => 'submit',
202
            'id'    => 'submit',
203
            'value' => $this->setLabel('bc')
204
        ]);
205
        $sReturn[]   = $this->setFormRow($this->setLabel('fd'), $btn, 1);
206
        $frm         = $this->setStringIntoTag($this->setStringIntoTag(implode('', $sReturn), 'table'), 'form', [
207
            'method' => 'get',
208
            'action' => $this->tCmnSuperGlobals->getScriptName()
209
        ]);
210
        $aryFieldSet = [
211
            $this->setStringIntoTag($this->tApp->gettext('i18n_FieldsetLabel_Inputs'), 'legend'),
212
            $frm
213
        ];
214
        return $this->setStringIntoTag(implode('', $aryFieldSet), 'fieldset', ['style' => 'float: left;']);
215
    }
216
217
    private function setFormInputElements()
218
    {
219
        $sReturn   = [];
220
        $sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM(), 1);
221
        $sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1);
222
        $sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 2, '%'), 1);
223
        $sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1);
224
        $sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1);
225
        $sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, ''), 1);
226
        $sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, ''), 1);
227
        $sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1);
228
        $sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1);
229
        $sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1);
230
        $sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, ''), 1);
231
        $sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1);
232
        $sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1);
233
        return $sReturn;
234
    }
235
236
    private function setFormInputSelectPC()
237
    {
238
        $choices = [
239
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceNo'),
240
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceYes'),
241
        ];
242
        return $this->setArrayToSelect($choices, $this->tCmnSuperGlobals->get('pc'), 'pc', ['size' => 1]);
243
    }
244
245
    private function setFormInputSelectPI()
246
    {
247
        $temp2 = [];
248
        for ($counter = 0; $counter <= 4; $counter++) {
249
            $temp2[$counter] = $counter . ($counter == 4 ? '+' : '');
250
        }
251
        return $this->setArrayToSelect($temp2, $this->tCmnSuperGlobals->get('pi'), 'pi', ['size' => 1]);
252
    }
253
254
    private function setFormInputSelectYM()
255
    {
256
        $temp = [];
257
        for ($counter = date('Y'); $counter >= 2001; $counter--) {
258
            for ($counter2 = 12; $counter2 >= 1; $counter2--) {
259
                $crtDate = mktime(0, 0, 0, $counter2, 1, $counter);
260
                if ($crtDate <= mktime(0, 0, 0, date('m'), 1, date('Y'))) {
261
                    $temp[$crtDate] = strftime('%Y, %m (%B)', $crtDate);
262
                }
263
            }
264
        }
265
        return $this->setArrayToSelect($temp, $this->tCmnSuperGlobals->get('ym'), 'ym', ['size' => 1]);
266
    }
267
268
    private function setFormInputText($inName, $inSize, $inAfterLabel)
269
    {
270
        $inputParameters = [
271
            'type'      => 'text',
272
            'name'      => $inName,
273
            'value'     => $this->tCmnSuperGlobals->get($inName),
274
            'size'      => $inSize,
275
            'maxlength' => $inSize,
276
        ];
277
        return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel;
278
    }
279
280
    private function setFormOutput($configPath)
281
    {
282
        $aryStngs  = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute');
283
        $sReturn   = [];
284
        $overtime  = $this->getOvertimes($aryStngs['Monthly Average Working Hours']);
285
        $additions = $this->tCmnSuperGlobals->get('pb') + $overtime['os175'] + $overtime['os200'];
286
        $brut      = ($this->tCmnSuperGlobals->get('sn') * (1 + $this->tCmnSuperGlobals->get('sc') / 100) + $additions) * pow(10, 4);
287
        $text      = $this->tApp->gettext('i18n_Form_Label_ExchangeRateAtDate');
288
        $xRate     = str_replace('%1', date('d.m.Y', $this->currencyDetails['CXD']), $text);
289
        $sReturn[] = $this->setFormRow($xRate, 1000000);
290
        $text      = $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary');
291
        $sReturn[] = $this->setFormRow($text, $this->tCmnSuperGlobals->get('sn') * 10000);
292
        $prima     = $this->tCmnSuperGlobals->get('sn') * $this->tCmnSuperGlobals->get('sc') * 100;
293
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_CumulatedAddedValue'), $prima);
294
        $text      = $this->tApp->gettext('i18n_Form_Label_AdditionalBruttoAmount');
295
        $sReturn[] = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pb') * 10000);
296
        $ovTime    = [
297
            'main' => $this->tApp->gettext('i18n_Form_Label_OvertimeAmount'),
298
            1      => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice1'),
299
            2      => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice2'),
300
        ];
301
        $sReturn[] = $this->setFormRow(sprintf($ovTime['main'], $ovTime[1], '175%'), ($overtime['os175'] * pow(10, 4)));
302
        $sReturn[] = $this->setFormRow(sprintf($ovTime['main'], $ovTime[2], '200%'), ($overtime['os200'] * pow(10, 4)));
303
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_BruttoSalary'), $brut);
304
        $brut      += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
305
        $amount    = $this->getValues($brut, $aryStngs);
306
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PensionFund'), $amount['cas']);
307
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_UnemploymentTax'), $amount['somaj']);
308
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_HealthTax'), $amount['sanatate']);
309
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PersonalDeduction'), $amount['pd']);
310
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_ExciseTax'), $amount['impozit']);
311
        $retineri  = $amount['cas'] + $amount['somaj'] + $amount['sanatate'] + $amount['impozit'];
312
        $net       = $brut - $retineri + $this->tCmnSuperGlobals->get('pn') * 10000;
313
        $text      = $this->tApp->gettext('i18n_Form_Label_AdditionalNettoAmount');
314
        $sReturn[] = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pn') * 10000);
315
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_NettoSalary'), $net);
316
        $text      = $this->tApp->gettext('i18n_Form_Label_SeisureAmout');
317
        $sReturn[] = $this->setFormRow($text, $this->tCmnSuperGlobals->get('szamnt') * 10000);
318
        $text      = $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash');
319
        $sReturn[] = $this->setFormRow($text, ($net - $this->tCmnSuperGlobals->get('szamnt') * 10000));
320
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_WorkingDays'), $amount['zile'], 'value');
321
        $fBonus    = [
322
            'main'  => $this->tApp->gettext('i18n_Form_Label_FoodBonuses'),
323
            'no'    => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceNo'),
324
            'value' => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue')
325
        ];
326
        $fBonusTxt = sprintf($fBonus['main'], $fBonus['value'], $fBonus['no'], ($amount['zile'] - $this->tCmnSuperGlobals->get('zfb')));
327
        $sReturn[] = $this->setFormRow($fBonusTxt, $amount['ba']);
328
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_FoodBonusesValue'), $amount['gbns']);
329
        $total     = ($net + $amount['ba'] + $amount['gbns'] - $this->tCmnSuperGlobals->get('szamnt') * 10000);
330
        $sReturn[] = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_Total'), $total);
331
        setlocale(LC_TIME, explode('_', $this->tCmnSession->get('lang'))[0]);
332
        $crtMonth  = strftime('%B', $this->tCmnSuperGlobals->get('ym'));
333
        $legend    = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results')
334
            . '', $crtMonth, date('Y', $this->tCmnSuperGlobals->get('ym')));
335
        return $this->setStringIntoTag(implode('', [
336
                $this->setStringIntoTag($legend, 'legend'),
337
                $this->setStringIntoTag(implode('', $sReturn), 'table')
338
                ]), 'fieldset', ['style' => 'float: left;']);
339
    }
340
341
    private function setFormRow($text, $value, $type = 'amount')
342
    {
343
        $defaultCellStyle  = $this->setFormatRow($text, $value);
344
        $defaultCellStyle2 = [];
345
        switch ($type) {
346
            case 'amount':
347
                $value                      = $value / pow(10, 4);
348
                $defaultCellStyle2['style'] = $defaultCellStyle['style'] . 'text-align:right;';
349
                $cellValue                  = [];
350
                foreach ($this->currencyDetails['CX'] as $key2 => $value2) {
351
                    $fmt         = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY);
352
                    $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']);
353
                    $finalValue  = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2);
354
                    $cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle2);
355
                }
356
                $value2show        = implode('', $cellValue);
357
                break;
358
            case 'value':
359
                $defaultCellStyle2 = array_merge($defaultCellStyle, [
360
                    'colspan' => count($this->currencyDetails['CX'])
361
                ]);
362
                $value2show        = $this->setStringIntoTag($value, 'td', $defaultCellStyle2);
363
                break;
364
            default:
365
                $value2show        = $this->setStringIntoTag($value, 'td');
366
                break;
367
        }
368
        return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr');
369
    }
370
371
    private function setFormatRow($text, $value)
372
    {
373
        $defaultCellStyle = [
374
            'class' => 'labelS',
375
            'style' => 'color:#000;',
376
        ];
377
        $fieldsStyled     = $this->buildArrayOfFieldsStyled();
378
        if (array_key_exists($text, $fieldsStyled)) {
379
            $defaultCellStyle['style'] = $this->buildStyleForCellFormat($fieldsStyled[$text]);
380
        }
381
        if ((is_numeric($value)) && ($value == 0)) {
382
            $defaultCellStyle['style'] = 'color:#666;';
383
        }
384
        return $defaultCellStyle;
385
    }
386
387
    private function setHeaderHtml()
388
    {
389
        $headerParameters = [
390
            'lang'  => str_replace('_', '-', $this->tCmnSession->get('lang')),
391
            'title' => $this->tApp->gettext('i18n_ApplicationName'),
392
            'css'   => [
393
                'vendor/components/flag-icon-css/css/flag-icon.min.css',
394
                'Salariu/css/salariu.css',
395
            ],
396
        ];
397
        return $this->setHeaderCommon($headerParameters)
398
            . '<h1>' . $this->tApp->gettext('i18n_ApplicationName') . '</h1>';
399
    }
400
401
    private function setLabel($labelId)
402
    {
403
        $labelInfo = $this->appFlags['FI'][$labelId]['Label'];
404
        $sReturn   = '';
405
        if (is_array($labelInfo)) {
406
            if (count($labelInfo) == 3) {
407
                $pieces  = [
408
                    $this->tApp->gettext($labelInfo[0]),
409
                    $this->tApp->gettext($labelInfo[1]),
410
                ];
411
                $sReturn = sprintf($pieces[0], $pieces[1], $labelInfo[2]);
412
            }
413
        } elseif (is_string($labelInfo)) {
414
            $sReturn = $this->tApp->gettext($labelInfo);
415
        }
416
        return $this->setLabelSuffix($sReturn);
417
    }
418
419
    private function setLabelSuffix($text)
420
    {
421
        $suffix = '';
422
        if (!in_array($text, ['', '&nbsp;']) && (strpos($text, '<input') === false) && (substr($text, -1) !== '!')) {
423
            $suffix = ':';
424
        }
425
        return $text . $suffix;
426
    }
427
}
428