Guts::getData()   B
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 29
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 29
rs 8.5806
cc 4
eloc 14
nc 8
nop 2
1
<?php
2
3
namespace Xls\Record;
4
5
class Guts extends AbstractRecord
6
{
7
    const NAME = 'GUTS';
8
    const ID = 0x0080;
9
10
    /**
11
     * Generate the GUTS BIFF record. This is used to configure the gutter margins
12
     * where Excel outline symbols are displayed. The visibility of the gutters is
13
     * controlled by a flag in WSBOOL.
14
     *
15
     * @param $colInfo
16
     * @param $outlineRowLevel
17
     *
18
     * @return string
19
     */
20
    public function getData($colInfo, $outlineRowLevel)
21
    {
22
        $dxRwGut = 0x0000; // Size of row gutter
23
        $dxColGut = 0x0000; // Size of col gutter
24
25
        $rowLevel = $outlineRowLevel;
26
        $colLevel = 0;
27
28
        // Calculate the maximum column outline level. The equivalent calculation
29
        // for the row outline level is carried out in setRow().
30
        foreach ($colInfo as $col) {
31
            $colLevel = max($col['level'], $colLevel);
32
        }
33
34
        // Set the limits for the outline levels (0 <= x <= 7).
35
        $colLevel = max(0, min($colLevel, 7));
36
37
        // The displayed level is one greater than the max outline levels
38
        if ($rowLevel) {
39
            $rowLevel++;
40
        }
41
        if ($colLevel) {
42
            $colLevel++;
43
        }
44
45
        $data = pack("vvvv", $dxRwGut, $dxColGut, $rowLevel, $colLevel);
46
47
        return $this->getFullRecord($data);
48
    }
49
}
50