Completed
Push — master ( da2a08...b6c749 )
by Daniel
02:43
created

Salariu::getValuesPrimary()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 2
eloc 18
nc 2
nop 3
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
        $aReturn           = $this->getValuesPrimary($inDate, $lngBase, $aStngs);
97
        $pdVal             = [
98
            $inDate,
99
            ($lngBase + $aReturn['ba']),
100
            $this->tCmnSuperGlobals->get('pi'),
101
            $aStngs['Personal Deduction'],
102
        ];
103
        $aReturn['pd']     = $this->setPersonalDeduction($pdVal[0], $pdVal[1], $pdVal[2], $pdVal[3]);
104
        $restArrayToDeduct = [
105
            $aReturn['cas'],
106
            $aReturn['sanatate'],
107
            $aReturn['somaj'],
108
            $aReturn['pd'],
109
        ];
110
        $rest              = $lngBase - array_sum($restArrayToDeduct);
111
        if ($inDate >= mktime(0, 0, 0, 7, 1, 2010)) {
112
            $rest += round($aReturn['ba'], -4);
113
            if ($inDate >= mktime(0, 0, 0, 10, 1, 2010)) {
114
                $aReturn['gbns'] = $this->tCmnSuperGlobals->get('gbns') * pow(10, 4);
115
                $rest            += round($aReturn['gbns'], -4);
116
            }
117
        }
118
        $rest               += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
119
        $aReturn['impozit'] = $this->setIncomeTax($inDate, $rest, $aStngs['Income Tax']);
120
        return $aReturn;
121
    }
122
123
    private function getValuesPrimary($inDate, $lngBase, $aStngs)
124
    {
125
        $inDT             = new \DateTime(date('Y/m/d', $inDate));
126
        $wkDay            = $this->setWorkingDaysInMonth($inDT, $this->tCmnSuperGlobals->get('pc'));
127
        $nMealDays        = ($wkDay - $this->tCmnSuperGlobals->get('zfb'));
128
        $shLbl            = [
129
            'HFP'  => 'Health Fund Percentage',
130
            'HFUL' => 'Health Fund Upper Limit',
131
            'HTP'  => 'Health Tax Percentage',
132
            'MTV'  => 'Meal Ticket Value',
133
        ];
134
        $unemploymentBase = $lngBase;
135
        if ($this->tCmnSuperGlobals->get('ym') < mktime(0, 0, 0, 1, 1, 2008)) {
136
            $unemploymentBase = $this->tCmnSuperGlobals->get('sn');
137
        }
138
        return [
139
            'ba'       => $this->setFoodTicketsValue($inDate, $aStngs[$shLbl['MTV']]) * $nMealDays,
140
            'cas'      => $this->setHealthFundTax($inDate, $lngBase, $aStngs[$shLbl['HFP']], $aStngs[$shLbl['HFUL']]),
141
            'sanatate' => $this->setHealthTax($inDate, $lngBase, $aStngs[$shLbl['HTP']]),
142
            'somaj'    => $this->setUnemploymentTax($inDate, $unemploymentBase),
143
            'zile'     => $wkDay,
144
        ];
145
    }
146
147
    private function handleLocalizationSalariu($appSettings)
148
    {
149
        $this->handleLocalizationSalariuInputsIntoSession($appSettings);
150
        $this->handleLocalizationSalariuSafe($appSettings);
151
        $localizationFile = 'Salariu/locale/' . $this->tCmnSession->get('lang') . '/LC_MESSAGES/salariu.mo';
152
        $translations     = new \Gettext\Translations;
153
        $translations->addFromMoFile($localizationFile);
154
        $this->tApp       = new \Gettext\Translator();
155
        $this->tApp->loadTranslations($translations);
156
    }
157
158
    private function handleLocalizationSalariuInputsIntoSession($appSettings)
159
    {
160
        if (is_null($this->tCmnSuperGlobals->get('lang')) && is_null($this->tCmnSession->get('lang'))) {
161
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
162
        } elseif (!is_null($this->tCmnSuperGlobals->get('lang'))) {
163
            $this->tCmnSession->set('lang', filter_var($this->tCmnSuperGlobals->get('lang'), FILTER_SANITIZE_STRING));
164
        }
165
    }
166
167
    /**
168
     * to avoid potential language injections from other applications that do not applies here
169
     */
170
    private function handleLocalizationSalariuSafe($appSettings)
171
    {
172
        if (!array_key_exists($this->tCmnSession->get('lang'), $appSettings['Available Languages'])) {
173
            $this->tCmnSession->set('lang', $appSettings['Default Language']);
174
        }
175
    }
176
177
    private function processFormInputDefaults($inDefaultValues)
178
    {
179
        if (is_null($this->tCmnSuperGlobals->get('ym'))) {
180
            $this->tCmnSuperGlobals->request->set('ym', mktime(0, 0, 0, date('m'), 1, date('Y')));
181
        }
182
        foreach ($inDefaultValues as $key => $value) {
183
            if (is_null($this->tCmnSuperGlobals->get($key))) {
184
                $this->tCmnSuperGlobals->request->set($key, $value);
185
            }
186
        }
187
    }
188
189
    private function setFooterHtml($appSettings)
190
    {
191
        $sReturn = $this->setUpperRightBoxLanguages($appSettings['Available Languages'])
192
            . '<div class="resetOnly author">&copy; ' . date('Y') . ' '
193
            . $appSettings['Copyright Holder'] . '</div>'
194
            . '<hr/>'
195
            . '<div class="disclaimer">'
196
            . $this->tApp->gettext('i18n_Disclaimer')
197
            . '</div>';
198
        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...
199
    }
200
201
    private function setFormInput()
202
    {
203
        $sReturn     = $this->setFormInputElements();
204
        $btn         = $this->setStringIntoShortTag('input', [
205
            'type'  => 'submit',
206
            'id'    => 'submit',
207
            'value' => $this->setLabel('bc')
208
        ]);
209
        $sReturn[]   = $this->setFormRow($this->setLabel('fd'), $btn, 1);
210
        $frm         = $this->setStringIntoTag($this->setStringIntoTag(implode('', $sReturn), 'table'), 'form', [
211
            'method' => 'get',
212
            'action' => $this->tCmnSuperGlobals->getScriptName()
213
        ]);
214
        $aryFieldSet = [
215
            $this->setStringIntoTag($this->tApp->gettext('i18n_FieldsetLabel_Inputs'), 'legend'),
216
            $frm
217
        ];
218
        return $this->setStringIntoTag(implode('', $aryFieldSet), 'fieldset', ['style' => 'float: left;']);
219
    }
220
221
    private function setFormInputElements()
222
    {
223
        $sReturn   = [];
224
        $sReturn[] = $this->setFormRow($this->setLabel('ym'), $this->setFormInputSelectYM(), 1);
225
        $sReturn[] = $this->setFormRow($this->setLabel('sn'), $this->setFormInputText('sn', 10, 'RON'), 1);
226
        $sReturn[] = $this->setFormRow($this->setLabel('sc'), $this->setFormInputText('sc', 2, '%'), 1);
227
        $sReturn[] = $this->setFormRow($this->setLabel('pb'), $this->setFormInputText('pb', 10, 'RON'), 1);
228
        $sReturn[] = $this->setFormRow($this->setLabel('pn'), $this->setFormInputText('pn', 10, 'RON'), 1);
229
        $sReturn[] = $this->setFormRow($this->setLabel('os175'), $this->setFormInputText('os175', 2, ''), 1);
230
        $sReturn[] = $this->setFormRow($this->setLabel('os200'), $this->setFormInputText('os200', 2, ''), 1);
231
        $sReturn[] = $this->setFormRow($this->setLabel('pi'), $this->setFormInputSelectPI(), 1);
232
        $sReturn[] = $this->setFormRow($this->setLabel('pc'), $this->setFormInputSelectPC(), 1);
233
        $sReturn[] = $this->setFormRow($this->setLabel('szamnt'), $this->setFormInputText('szamnt', 10, 'RON'), 1);
234
        $sReturn[] = $this->setFormRow($this->setLabel('zfb'), $this->setFormInputText('zfb', 2, ''), 1);
235
        $sReturn[] = $this->setFormRow($this->setLabel('gbns'), $this->setFormInputText('gbns', 10, 'RON'), 1);
236
        $sReturn[] = $this->setFormRow($this->setLabel('afet'), $this->setFormInputText('afet', 10, 'RON'), 1);
237
        return $sReturn;
238
    }
239
240
    private function setFormInputSelectPC()
241
    {
242
        $choices = [
243
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceNo'),
244
            $this->tApp->gettext('i18n_Form_Label_CatholicEasterFree_ChoiceYes'),
245
        ];
246
        return $this->setArrayToSelect($choices, $this->tCmnSuperGlobals->get('pc'), 'pc', ['size' => 1]);
247
    }
248
249
    private function setFormInputSelectPI()
250
    {
251
        $temp2 = [];
252
        for ($counter = 0; $counter <= 4; $counter++) {
253
            $temp2[$counter] = $counter . ($counter == 4 ? '+' : '');
254
        }
255
        return $this->setArrayToSelect($temp2, $this->tCmnSuperGlobals->get('pi'), 'pi', ['size' => 1]);
256
    }
257
258
    private function setFormInputSelectYM()
259
    {
260
        $temp = [];
261
        for ($counter = date('Y'); $counter >= 2001; $counter--) {
262
            for ($counter2 = 12; $counter2 >= 1; $counter2--) {
263
                $crtDate = mktime(0, 0, 0, $counter2, 1, $counter);
264
                if ($crtDate <= mktime(0, 0, 0, date('m'), 1, date('Y'))) {
265
                    $temp[$crtDate] = strftime('%Y, %m (%B)', $crtDate);
266
                }
267
            }
268
        }
269
        return $this->setArrayToSelect($temp, $this->tCmnSuperGlobals->get('ym'), 'ym', ['size' => 1]);
270
    }
271
272
    private function setFormInputText($inName, $inSize, $inAfterLabel)
273
    {
274
        $inputParameters = [
275
            'type'      => 'text',
276
            'name'      => $inName,
277
            'value'     => $this->tCmnSuperGlobals->get($inName),
278
            'size'      => $inSize,
279
            'maxlength' => $inSize,
280
        ];
281
        return $this->setStringIntoShortTag('input', $inputParameters) . ' ' . $inAfterLabel;
282
    }
283
284
    private function setFormOutput($configPath)
285
    {
286
        $aryStngs    = $this->readTypeFromJsonFileUniversal($configPath, 'valuesToCompute');
287
        $sReturn     = [];
288
        $ovTimeVal   = $this->getOvertimes($aryStngs['Monthly Average Working Hours']);
289
        $additions   = $this->tCmnSuperGlobals->get('pb') + $ovTimeVal['os175'] + $ovTimeVal['os200'];
290
        $bComponents = [
291
            'sc' => $this->tCmnSuperGlobals->get('sc'),
292
            'sn' => $this->tCmnSuperGlobals->get('sn'),
293
        ];
294
        $brut        = ($bComponents['sn'] * (1 + $bComponents['sc'] / 100) + $additions) * pow(10, 4);
295
        $text        = $this->tApp->gettext('i18n_Form_Label_ExchangeRateAtDate');
296
        $xRate       = str_replace('%1', date('d.m.Y', $this->currencyDetails['CXD']), $text);
297
        $sReturn[]   = $this->setFormRow($xRate, 10000000);
298
        $text        = $this->tApp->gettext('i18n_Form_Label_NegotiatedSalary');
299
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('sn') * 10000);
300
        $prima       = $this->tCmnSuperGlobals->get('sn') * $this->tCmnSuperGlobals->get('sc') * 100;
301
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_CumulatedAddedValue'), $prima);
302
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalBruttoAmount');
303
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pb') * 10000);
304
        $ovTime      = [
305
            'm' => $this->tApp->gettext('i18n_Form_Label_OvertimeAmount'),
306
            1   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice1'),
307
            2   => $this->tApp->gettext('i18n_Form_Label_OvertimeChoice2'),
308
        ];
309
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[1], '175%'), ($ovTimeVal['os175'] * pow(10, 4)));
310
        $sReturn[]   = $this->setFormRow(sprintf($ovTime['m'], $ovTime[2], '200%'), ($ovTimeVal['os200'] * pow(10, 4)));
311
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_BruttoSalary'), $brut);
312
        $brut        += $this->tCmnSuperGlobals->get('afet') * pow(10, 4);
313
        $amount      = $this->getValues($brut, $aryStngs);
314
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PensionFund'), $amount['cas']);
315
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_UnemploymentTax'), $amount['somaj']);
316
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_HealthTax'), $amount['sanatate']);
317
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_PersonalDeduction'), $amount['pd']);
318
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_ExciseTax'), $amount['impozit']);
319
        $retineri    = $amount['cas'] + $amount['somaj'] + $amount['sanatate'] + $amount['impozit'];
320
        $net         = $brut - $retineri + $this->tCmnSuperGlobals->get('pn') * 10000;
321
        $text        = $this->tApp->gettext('i18n_Form_Label_AdditionalNettoAmount');
322
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('pn') * 10000);
323
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_NettoSalary'), $net);
324
        $text        = $this->tApp->gettext('i18n_Form_Label_SeisureAmout');
325
        $sReturn[]   = $this->setFormRow($text, $this->tCmnSuperGlobals->get('szamnt') * 10000);
326
        $text        = $this->tApp->gettext('i18n_Form_Label_NettoSalaryCash');
327
        $sReturn[]   = $this->setFormRow($text, ($net - $this->tCmnSuperGlobals->get('szamnt') * 10000));
328
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_WorkingDays'), $amount['zile'], 'value');
329
        $fBonus      = [
330
            'main'   => $this->tApp->gettext('i18n_Form_Label_FoodBonuses'),
331
            'no'     => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceNo'),
332
            'value'  => $this->tApp->gettext('i18n_Form_Label_FoodBonusesChoiceValue'),
333
            'mtDays' => ($amount['zile'] - $this->tCmnSuperGlobals->get('zfb'))
334
        ];
335
        $fBonusTxt   = sprintf($fBonus['main'], $fBonus['value'], $fBonus['no'], $fBonus['mtDays']);
336
        $sReturn[]   = $this->setFormRow($fBonusTxt, $amount['ba']);
337
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_FoodBonusesValue'), $amount['gbns']);
338
        $total       = ($net + $amount['ba'] + $amount['gbns'] - $this->tCmnSuperGlobals->get('szamnt') * 10000);
339
        $sReturn[]   = $this->setFormRow($this->tApp->gettext('i18n_Form_Label_Total'), $total);
340
        setlocale(LC_TIME, explode('_', $this->tCmnSession->get('lang'))[0]);
341
        $crtMonth    = strftime('%B', $this->tCmnSuperGlobals->get('ym'));
342
        $legend      = sprintf($this->tApp->gettext('i18n_FieldsetLabel_Results')
343
            . '', $crtMonth, date('Y', $this->tCmnSuperGlobals->get('ym')));
344
        return $this->setStringIntoTag(implode('', [
345
                $this->setStringIntoTag($legend, 'legend'),
346
                $this->setStringIntoTag(implode('', $sReturn), 'table')
347
                ]), 'fieldset', ['style' => 'float: left;']);
348
    }
349
350
    private function setFormRow($text, $value, $type = 'amount')
351
    {
352
        $defaultCellStyle = $this->setFormatRow($text, $value);
353
        switch ($type) {
354
            case 'amount':
355
                $value2show = $this->setFormRowAmount(($value / pow(10, 4)), $defaultCellStyle);
356
                break;
357
            case 'value':
358
                $value2show = $this->setStringIntoTag($value, 'td', array_merge($defaultCellStyle, [
359
                    'colspan' => count($this->currencyDetails['CX'])
360
                ]));
361
                break;
362
            default:
363
                $value2show = $this->setStringIntoTag($value, 'td');
364
                break;
365
        }
366
        return $this->setStringIntoTag($this->setStringIntoTag($text, 'td', $defaultCellStyle) . $value2show, 'tr');
367
    }
368
369
    private function setFormRowAmount($value, $defaultCellStyle)
370
    {
371
        $cellValue                 = [];
372
        $defaultCellStyle['style'] .= 'text-align:right;';
373
        foreach ($this->currencyDetails['CX'] as $key2 => $value2) {
374
            $fmt         = new \NumberFormatter($value2['locale'], \NumberFormatter::CURRENCY);
375
            $fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, $value2['decimals']);
376
            $finalValue  = $fmt->formatCurrency($value / $this->currencyDetails['CXV'][$key2], $key2);
377
            $cellValue[] = $this->setStringIntoTag($finalValue, 'td', $defaultCellStyle);
378
        }
379
        return implode('', $cellValue);
380
    }
381
382
    private function setFormatRow($text, $value)
383
    {
384
        $defaultCellStyle = [
385
            'class' => 'labelS',
386
            'style' => 'color:#000;',
387
        ];
388
        $fieldsStyled     = $this->buildArrayOfFieldsStyled();
389
        if (array_key_exists($text, $fieldsStyled)) {
390
            $defaultCellStyle['style'] = $this->buildStyleForCellFormat($fieldsStyled[$text]);
391
        }
392
        if ((is_numeric($value)) && ($value == 0)) {
393
            $defaultCellStyle['style'] = 'color:#666;';
394
        }
395
        return $defaultCellStyle;
396
    }
397
398
    private function setHeaderHtml()
399
    {
400
        $headerParameters = [
401
            'lang'  => str_replace('_', '-', $this->tCmnSession->get('lang')),
402
            'title' => $this->tApp->gettext('i18n_ApplicationName'),
403
            'css'   => [
404
                'vendor/components/flag-icon-css/css/flag-icon.min.css',
405
                'Salariu/css/salariu.css',
406
            ],
407
        ];
408
        return $this->setHeaderCommon($headerParameters)
409
            . '<h1>' . $this->tApp->gettext('i18n_ApplicationName') . '</h1>';
410
    }
411
412
    private function setLabel($labelId)
413
    {
414
        $labelInfo = $this->appFlags['FI'][$labelId]['Label'];
415
        $sReturn   = '';
416
        if (is_array($labelInfo)) {
417
            if (count($labelInfo) == 3) {
418
                $pieces  = [
419
                    $this->tApp->gettext($labelInfo[0]),
420
                    $this->tApp->gettext($labelInfo[1]),
421
                ];
422
                $sReturn = sprintf($pieces[0], $pieces[1], $labelInfo[2]);
423
            }
424
        } elseif (is_string($labelInfo)) {
425
            $sReturn = $this->tApp->gettext($labelInfo);
426
        }
427
        return $this->setLabelSuffix($sReturn);
428
    }
429
430
    private function setLabelSuffix($text)
431
    {
432
        $suffix = '';
433
        if (!in_array($text, ['', '&nbsp;']) && (strpos($text, '<input') === false) && (substr($text, -1) !== '!')) {
434
            $suffix = ':';
435
        }
436
        return $text . $suffix;
437
    }
438
}
439