Passed
Push — master ( ab3dee...cb29e2 )
by Daniel
02:51
created

trolWithTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 * The MIT License (MIT)
6
 *
7
 * Copyright (c) 2015 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\common_lib;
30
31
/**
32
 * DOM component functions
33
 *
34
 * @author Daniel Popiniuc
35
 */
36
trait DomComponentsByDanielGP
37
{
38
39
    use CommonBasic,
40
        DomHeaderFooterByDanielGP;
41
42
    /**
43
     * Returns a table from an query
44
     *
45
     * @param array $aElements
46
     * @param array $ftrs
47
     * @param boolean $bKpFlPge
48
     * @return string
49
     */
50
    protected function setArrayToTable($aElements, $ftrs = [], $bKpFlPge = true)
51
    {
52
        $rows = count($aElements);
53
        if ($rows == 0) {
54
            $divTab = [
55
                'start' => '',
56
                'end'   => '',
57
            ];
58
            if (array_key_exists('showGroupingCounter', $ftrs)) {
59
                if (array_key_exists('grouping_cell_type', $ftrs) && ($ftrs['grouping_cell_type'] == 'tab')) {
60
                    $ditTitle = 'No data found';
61
                    if (isset($ftrs['showGroupingCounter'])) {
62
                        $ditTitle .= ' (0)';
63
                    }
64
                    $divTab = [
65
                        'start' => '<div class="tabbertab tabbertabdefault" id="tab_NoData" title="' . $ditTitle . '">',
66
                        'end'   => '</div><!-- from tab_NoData -->',
67
                    ];
68
                    if (!isset($ftrs['noGlobalTab'])) {
69
                        $divTab = [
70
                            'start' => '<div class="tabber" id="tab">' . $divTab['start'],
71
                            'end'   => $divTab['end'] . '</div><!-- from global Tab -->',
72
                        ];
73
                    }
74
                }
75
            }
76
            return $divTab['start']
77
                . $this->setFeedbackModern('error', 'Error', $this->lclMsgCmn('i18n_NoData'))
78
                . $divTab['end'];
79
        }
80
        if (isset($ftrs['limits'])) {
81
            $ftrs['limits'][1] = min($ftrs['limits'][1], $ftrs['limits'][2]);
82
            if ($ftrs['limits'][2] > $ftrs['limits'][1]) {
83
                $iStartingPageRecord = 1;
84
            }
85
        }
86
        $sReturn = '';
87
        if (isset($ftrs['hidden_columns'])) {
88
            $hdClmns = $this->setArrayValuesAsKey($ftrs['hidden_columns']);
89
        } else {
90
            $hdClmns = [''];
91
        }
92
        $checkboxFormId = '';
93
        if ((isset($ftrs['actions']['checkbox_inlineEdit'])) || (isset($ftrs['actions']['checkbox']))) {
94
            $checkboxFormId = 'frm' . date('YmdHis');
95
            $sReturn        .= '<form id="' . $checkboxFormId . '" name="' . $checkboxFormId
96
                . '" method="post" ' . ' action="' . $this->tCmnRequest->server->get('PHP_SELF') . '" >';
97
        }
98
        $tbl        = [];
99
        $tbl['Def'] = '<table'
100
            . (isset($ftrs['table_style']) ? ' style="' . $ftrs['table_style'] . '"' : '')
101
            . (isset($ftrs['table_class']) ? ' class="' . $ftrs['table_class'] . '"' : '')
102
            . '>';
103
        if (!isset($ftrs['grouping_cell_type'])) {
104
            $ftrs['grouping_cell_type'] = 'row';
105
        }
106
        switch ($ftrs['grouping_cell_type']) {
107
            case 'row':
108
                $sReturn .= $tbl['Def'];
109
                break;
110
            case 'tab':
111
                if (!isset($ftrs['noGlobalTab'])) {
112
                    $sReturn .= '<div class="tabber" id="tab">';
113
                }
114
                break;
115
        }
116
        $groupCounter     = 0;
117
        $iTableColumns    = 0;
118
        $remebered_value  = -1;
119
        $remindGroupValue = null;
120
        $color_no         = null;
121
        if (!isset($ftrs['headers_breaked'])) {
122
            $ftrs['headers_breaked'] = true;
123
        }
124
        for ($rCntr = 0; $rCntr < $rows; $rCntr++) {
125
            if ($rCntr == 0) {
126
                $header        = array_diff_key($aElements[$rCntr], $hdClmns);
127
                $iTableColumns = count($header);
128
                if (isset($ftrs['computed_columns'])) {
129
                    $iTableColumns += count($ftrs['computed_columns']);
130
                }
131
                if (isset($ftrs['actions'])) {
132
                    $iTableColumns += 1;
133
                }
134
                if (isset($ftrs['grouping_cell'])) {
135
                    $iTableColumns -= 1;
136
                }
137
                $tbl['Head'] = '<thead>';
138
                if ($ftrs['grouping_cell_type'] == 'row') {
139
                    $sReturn .= $tbl['Head'];
140
                }
141
                if (isset($iStartingPageRecord)) {
142
                    $pgn     = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2], $bKpFlPge);
143
                    $sReturn .= $this->setStringIntoTag($this->setStringIntoTag($pgn, 'th', [
144
                            'colspan' => $iTableColumns
145
                        ]), 'tr');
146
                }
147
                $tbl['Header'] = '<tr>';
148
                if (isset($ftrs['grouping_cell'])) { // Grouping columns
149
                    $header = array_diff_key($header, [$ftrs['grouping_cell'] => '']);
150
                }
151
                if (isset($ftrs['actions'])) { // Action column
152
                    $tbl['Header'] .= '<th>&nbsp;</th>';
153
                }
154
                if (isset($ftrs['RowStyle'])) { //Exclude style columns from displaying
155
                    $tmpClmns = $this->setArrayValuesAsKey([$ftrs['RowStyle']]);
156
                    $header   = array_diff_key($header, $tmpClmns);
157
                    $hdClmns  = array_merge($hdClmns, $tmpClmns);
158
                    unset($tmpClmns);
159
                }
160
                $tbl['Header'] .= $this->setTableHeader($header, $ftrs['headers_breaked']); // Regular columns
161
                if (isset($ftrs['computed_columns'])) { // Computed columns
162
                    $tbl['Header'] .= $this->setTableHeader($ftrs['computed_columns'], $ftrs['headers_breaked']);
163
                }
164
                $tbl['Header'] .= '</tr></thead><tbody>';
165
                if ($ftrs['grouping_cell_type'] == 'row') {
166
                    $sReturn .= $tbl['Header'];
167
                }
168
            }
169
            $row_current = array_diff_key($aElements[$rCntr], $hdClmns);
170
            if (isset($ftrs['row_colored_alternated'])) {
171
                if ($ftrs['row_colored_alternated'][0] == '#') {
172
                    $color_column_value = $rCntr;
173
                } else {
174
                    $color_column_value = $row_current[$ftrs['row_colored_alternated'][0]];
175
                }
176
                if ($remebered_value != $color_column_value) {
177
                    if (isset($color_no)) {
178
                        $color_no = 1;
179
                    } else {
180
                        $color_no = 2;
181
                    }
182
                    $remebered_value = $color_column_value;
183
                }
184
                $color = ' style="background-color: ' . $ftrs['row_colored_alternated'][$color_no] . ';"';
185
            } else {
186
                if (isset($ftrs['RowStyle'])) {
187
                    $color = ' style="' . $aElements[$rCntr][$ftrs['RowStyle']] . '"';
188
                } else {
189
                    $color = '';
190
                }
191
            }
192
            $tbl['tr_Color'] = '<tr' . $color . '>';
193
// Grouping column
194
            if (isset($ftrs['grouping_cell'])) {
195
                foreach ($aElements[$rCntr] as $key => $value) {
196
                    if (($ftrs['grouping_cell'] == $key) && ($remindGroupValue != $value)) {
197
                        switch ($ftrs['grouping_cell_type']) {
198
                            case 'row':
199
                                $sReturn .= $tbl['tr_Color'] . '<td ' . 'colspan="' . $iTableColumns . '">'
200
                                    . $this->setStringIntoTag($value, 'div', ['class' => 'rowGroup rounded'])
201
                                    . '</td></tr>';
202
                                break;
203
                            case 'tab':
204
                                if (is_null($remindGroupValue)) {
205
                                    if (isset($ftrs['showGroupingCounter'])) {
206
                                        $groupCounter = 0;
207
                                    }
208
                                } else {
209
                                    $sReturn .= '</tbody></table>';
210
                                    if (isset($ftrs['showGroupingCounter'])) {
211
                                        $sReturn      .= $this->updateDivTitleName($remindGroupValue, $groupCounter);
212
                                        $groupCounter = 0;
213
                                    }
214
                                    $sReturn .= '</div>';
215
                                }
216
                                $sReturn .= '<div class="tabbertab';
217
                                if (isset($ftrs['grouping_default_tab'])) {
218
                                    $sReturn .= ($ftrs['grouping_default_tab'] == $value ? ' tabbertabdefault' : '');
219
                                }
220
                                $sReturn .= '" id="tab_' . $this->cleanStringForId($value) . '" '
221
                                    . 'title="' . $value . '">'
222
                                    . $tbl['Def'] . $tbl['Head'] . $tbl['Header'];
223
                                break;
224
                        }
225
                        $remindGroupValue = $value;
226
                    }
227
                }
228
            }
229
            if (isset($ftrs['grouping_cell'])) {
230
                if ($ftrs['grouping_cell_type'] == 'tab') {
231
                    if (isset($ftrs['showGroupingCounter'])) {
232
                        $groupCounter++;
233
                    }
234
                }
235
            }
236
            $sReturn       .= $tbl['tr_Color'];
237
// Action column
238
            $checkboxName  = '';
239
            $checkboxNameS = '';
240
            if (isset($ftrs['actions'])) {
241
                $sReturn         .= '<td style="white-space:nowrap;">';
242
                $action_argument = 0;
243
                if (isset($ftrs['actions']['key'])) {
244
                    $actionKey = $ftrs['actions']['key'];
245
                } else {
246
                    $actionKey = 'view';
247
                }
248
                if (isset($ftrs['action_prefix'])) {
249
                    $actPrfx   = $ftrs['action_prefix'] . '&amp;';
250
                    $actionKey = 'view2';
251
                } else {
252
                    $actPrfx = '';
253
                }
254
                foreach ($ftrs['actions'] as $key => $value) {
255
                    if ($action_argument != 0) {
256
                        $sReturn .= '&nbsp;';
257
                    }
258
                    switch ($key) {
259
                        case 'checkbox':
260
                            $checkboxName  = $value . '[]';
261
                            $checkboxNameS = $value;
262
                            $sReturn       .= '&nbsp;<input type="checkbox" name="' . $checkboxName
263
                                . '" id="n' . $aElements[$rCntr][$value]
264
                                . '" value="' . $aElements[$rCntr][$value] . '" ';
265
                            if (isset($_REQUEST[$checkboxNameS])) {
266
                                if (is_array($_REQUEST[$checkboxNameS])) {
267
                                    if (in_array($aElements[$rCntr][$value], $_REQUEST[$checkboxNameS])) {
268
                                        $sReturn .= 'checked="checked" ';
269
                                    }
270
                                } else {
271
                                    if ($aElements[$rCntr][$value] == $_REQUEST[$checkboxNameS]) {
272
                                        $sReturn .= 'checked="checked" ';
273
                                    }
274
                                }
275
                            }
276
                            if (strpos($_REQUEST['view'], 'multiEdit') !== false) {
277
                                $sReturn .= 'disabled="disabled" ';
278
                            }
279
                            $sReturn       .= '/>';
280
                            break;
281
                        case 'checkbox_inlineEdit':
282
                            $checkboxName  = $value . '[]';
283
                            $checkboxNameS = $value;
284
                            $sReturn       .= '&nbsp;<input type="checkbox" name="' . $checkboxName
285
                                . '" id="n' . $aElements[$rCntr][$value] . '" value="'
286
                                . $aElements[$rCntr][$value] . '"/>';
287
                            break;
288
                        case 'delete':
289
                            $sReturn       .= '<a href="#" onclick="javascript:setQuest(\'' . $value[0] . '\',\'';
290
                            $iActArgs      = count($value[1]);
291
                            for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) {
292
                                $sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]];
293
                            }
294
                            $sReturn .= '\');" id="' . $key . $rCntr . '"><i class="fa fa-times">&nbsp;</i></a>';
295
                            break;
296
                        case 'edit':
297
                        case 'list2':
298
                        case 'schedule':
299
                            $vIc     = ($key == 'edit' ? 'pencil' : ($key == 'list2' ? 'list' : 'hourglass-half'));
300
                            $sReturn .= $this->setDynamicActionToSpecialCell($value, $aElements, [
301
                                'vIcon'    => 'fa fa-' . $vIc,
302
                                'aPrefix'  => $actPrfx,
303
                                'aKey'     => $actionKey,
304
                                'rCounter' => $rCntr,
305
                                'Features' => $ftrs,
306
                                'key'      => $key,
307
                            ]);
308
                            break;
309
                    }
310
                    $action_argument += 1;
311
                }
312
                $sReturn .= '</td>';
313
            }
314
// Regular columns
315
            $sReturn .= $this->setTableCell($row_current, $ftrs);
316
// Computed columns
317
            if (isset($ftrs['computed_columns'])) {
318
                $rowComputed = [];
319
                $decimals    = [];
320
                foreach ($ftrs['computed_columns'] as $key => $value) {
321
                    if ($value[0] == '%') {
322
                        $dec = $value[2] + 2;
323
                    } else {
324
                        $dec = $value[2];
325
                    }
326
                    switch ($value[1]) {
327
                        case '/':
328
                            // next variable is only to avoid a long line
329
                            $shorter                 = [
330
                                $aElements[$rCntr][$value[3]],
331
                                $aElements[$rCntr][$value[4]],
332
                            ];
333
                            $aElements[$rCntr][$key] = $this->setDividedResult($shorter[0], $shorter[1], $dec);
334
                            break;
335
                        case '+':
336
                            // next variable is only to avoid a long line
337
                            $iTemp                   = $this->setArrayValuesAsKey([
338
                                $value[0],
339
                                $value[1],
340
                                $value[2]
341
                            ]);
342
                            $aTemp                   = array_diff($value, $iTemp);
343
                            $aElements[$rCntr][$key] = 0;
344
                            foreach ($aTemp as $sValue) {
345
                                $aElements[$rCntr][$key] += $aElements[$rCntr][$sValue];
346
                            }
347
                            break;
348
                        default:
349
                            $rowComputed[$key] = '';
350
                            break;
351
                    }
352
                    if ($value[0] == '%') {
353
                        $rowComputed[$key] = ($aElements[$rCntr][$key] * 100);
354
                        $dec               -= 2;
355
                    } else {
356
                        $rowComputed[$key] = $aElements[$rCntr][$key];
357
                    }
358
                    $decimals[$key] = $dec;
359
                }
360
// displaying them
361
                $sReturn .= $this->setTableCell($rowComputed, ['decimals' => $decimals]);
362
            }
363
            $sReturn .= '</tr>';
364
        }
365
        if (isset($iStartingPageRecord)) {
366
            $pgn     = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2]);
367
            $sReturn .= '<tr>' . $this->setStringIntoTag($pgn, 'th', ['colspan' => $iTableColumns]) . '</tr>';
368
        }
369
        $sReturn .= '</tbody></table>';
370
        if ($ftrs['grouping_cell_type'] == 'tab') {
371
            if (isset($ftrs['showGroupingCounter'])) {
372
                $sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter);
373
            }
374
            $sReturn .= '</div><!-- from ' . $remindGroupValue . ' -->';
375
            if (!isset($ftrs['noGlobalTab'])) {
376
                $sReturn .= '</div><!-- from global tab -->';
377
            }
378
        }
379
        if (isset($ftrs['actions']['checkbox'])) {
380
            if (strpos($_REQUEST['view'], 'multiEdit') === false) {
381
                $sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId
382
                    . '\',\'' . $checkboxName . '\',true);">Check All</a>&nbsp;&nbsp;'
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $checkboxName does not seem to be defined for all execution paths leading up to this point.
Loading history...
383
                    . '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId
384
                    . '\',\'' . $checkboxName . '\',false);">Uncheck All</a>&nbsp;&nbsp;'
385
                    . '<input type="hidden" name="action" value="multiEdit_' . $checkboxNameS . '" />';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $checkboxNameS does not seem to be defined for all execution paths leading up to this point.
Loading history...
386
                if (isset($ftrs['hiddenInput'])) {
387
                    if (is_array($ftrs['hiddenInput'])) {
388
                        foreach ($ftrs['hiddenInput'] as $valueF) {
389
                            $sReturn .= '<input type="hidden" name="' . $valueF
390
                                . '" value="' . $_REQUEST[$valueF] . '" />';
391
                        }
392
                    } else {
393
                        $sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput']
394
                            . '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />';
395
                    }
396
                }
397
                $sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" ' . 'value="Edit selected" />';
398
            }
399
            $sReturn .= '</form>';
400
        }
401
        if (isset($ftrs['actions']['checkbox_inlineEdit'])) {
402
            $sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId
403
                . '\',\'' . $checkboxName . '\',true);">Check All</a>&nbsp;&nbsp;'
404
                . '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId
405
                . '\',\'' . $checkboxName . '\',false);">Uncheck All</a>&nbsp;&nbsp;';
406
            if (isset($ftrs['visibleInput'])) {
407
                $sReturn .= $ftrs['visibleInput'];
408
            }
409
            $sReturn .= '<input type="hidden" name="view" value="save_' . $checkboxNameS . '" />';
410
            if (isset($ftrs['hiddenInput'])) {
411
                if (is_array($ftrs['hiddenInput'])) {
412
                    foreach ($ftrs['hiddenInput'] as $valueF) {
413
                        $sReturn .= '<input type="hidden" name="' . $valueF . '" value="' . $_REQUEST[$valueF] . '" />';
414
                    }
415
                } else {
416
                    $sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput']
417
                        . '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />';
418
                }
419
            }
420
            $sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" value="Store the modification" />';
421
            $sReturn .= '</form>';
422
        }
423
        return $sReturn;
424
    }
425
426
    private function setDynamicActionToSpecialCell($val, $aElements, $inP)
427
    {
428
        $aArgumemts   = [];
429
        $aArgumemts[] = $this->tCmnSuperGlobals->getScriptName() . '?' . $inP['aPrefix'] . $inP['aKey'] . '=' . $val[0];
430
        $iActArgs     = count($val[1]);
431
        for ($counter = 0; $counter < $iActArgs; $counter++) {
432
            $aArgumemts[] = $val[1][$counter] . '=' . $aElements[$inP['rCounter']][$val[1][$counter]];
433
        }
434
        $id = $inP['key'] . $inP['rCounter'];
435
        if (isset($inP['Features']['NoAjaxEditing'])) {
436
            return '<a href="' . implode('&amp;', $aArgumemts) . '" id="' . $id . '"><i class="'
437
                . $inP['vIcon'] . '">&nbsp;</i></a>';
438
        }
439
        return '<a href="#" onclick="javascript:loadAE(\'' . implode('&amp;', $aArgumemts) . '\');"'
440
            . ' id="' . $id . '"><i class="' . $inP['vIcon'] . '">&nbsp;</i></a>';
441
    }
442
443
    /**
444
     * Generates a table cell
445
     *
446
     * @param array $aElements
447
     * @param array $features
448
     * @return string
449
     */
450
    private function setTableCell($aElements, $features = null)
451
    {
452
        $sReturn = null;
453
        foreach ($aElements as $key => $value) {
454
            $value = str_replace(['& ', '\"', "\'"], ['&amp; ', '"', "'"], $value);
455
            if ((isset($features['grouping_cell'])) && ($features['grouping_cell'] == $key)) {
456
                // just skip
457
            } else {
458
                $sReturn .= '<td ';
459
                if (isset($features['column_formatting'][$key])) {
460
                    switch ($features['column_formatting'][$key]) {
461
                        case '@':
462
                            $sReturn .= 'style="text-align:left;">' . $value;
463
                            break;
464
                        case 'right':
465
                            $sReturn .= 'style="text-align:right;">' . $value;
466
                            break;
467
                        default:
468
                            $sReturn .= '???';
469
                            break;
470
                    }
471
                } else {
472
                    if (is_numeric($value)) {
473
                        $sReturn .= $this->setTableCellNumeric($key, $value, $features);
474
                    } else {
475
                        $outputet = false;
476
                        if ((strpos($value, '-') !== false) && (strlen($value) == 10)) {
477
                            if (preg_match("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $value, $regs)) {
478
                                $outputet = true;
479
                                $sReturn  .= 'style="text-align:right;width: 10px;">'
480
                                    . $regs[3] . '.' . $regs[2] . '.' . $regs[1];
481
                            }
482
                        }
483
                        if (!$outputet) {
484
                            $sReturn .= 'style="text-align:left;">' . $value;
485
                        }
486
                    }
487
                }
488
                $sReturn .= '</td>';
489
            }
490
        }
491
        return $sReturn;
492
    }
493
494
    private function setTableCellDecimals($key, $features)
495
    {
496
        $decimals = 0;
497
        if (isset($features['no_of_decimals'])) {
498
            $decimals = $features['no_of_decimals'];
499
        }
500
        if (isset($features['decimals']) && array_key_exists($key, $features['decimals'])) {
501
            $decimals = $features['decimals'][$key];
502
        }
503
        return $decimals;
504
    }
505
506
    private function setTableCellNumeric($key, $value, $features)
507
    {
508
        $styleToReturn = 'style="text-align: right;">';
509
        if (substr($value, 0, 1) === '0') {
510
            return $styleToReturn . $value;
511
        }
512
        $decimals = $this->setTableCellDecimals($key, $features);
513
        $nDc      = ['MinFractionDigits' => $decimals, 'MaxFractionDigits' => $decimals];
514
        return $styleToReturn . $this->setNumberFormat($value, $nDc);
515
    }
516
517
    /**
518
     * Generates a table header
519
     *
520
     * @param array $aElements
521
     * @param boolean $bHeadersBreaked
522
     * @return string
523
     */
524
    private function setTableHeader($aElements, $bHeadersBreaked)
525
    {
526
        $aTableHeader = $aElements;
527
        if ($bHeadersBreaked) {
528
            $aTableHeader = $this->setArrayToArrayKbr($aElements);
529
        }
530
        $sReturn[] = [];
0 ignored issues
show
Comprehensibility Best Practice introduced by
$sReturn was never initialized. Although not strictly required by PHP, it is generally a good practice to add $sReturn = array(); before regardless.
Loading history...
531
        foreach (array_keys($aTableHeader) as $value) {
532
            $sReturn[] = $this->setStringIntoTag($value, 'th');
533
        }
534
        return implode('', $sReturn);
535
    }
536
537
}
538