Row   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 74
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getData() 0 30 2
A getGrBit() 0 19 3
1
<?php
2
namespace Xls\Record;
3
4
class Row extends AbstractRecord
5
{
6
    const NAME = 'ROW';
7
    const ID = 0x0208;
8
9
    /**
10
     * @param array $rowInfo
11
     *
12
     * @return string
13
     */
14
    public function getData($rowInfo)
15
    {
16
        $colMic = 0x0000; // First defined column
17
        $colMac = 0x0000; // Last defined column
18
        $irwMac = 0x0000; // Used by Excel to optimise loading
19
        $reserved = 0x0000; // Reserved
20
21
        $height = $rowInfo['height'];
22
        if (!is_null($height)) {
23
            $height = $height * 20; // row height
24
        } else {
25
            $height = 0xff; // default row height is 256
26
        }
27
28
        $level = max(0, min($rowInfo['level'], 7)); // level should be between 0 and 7
29
30
        $data = pack(
31
            "vvvvvvvv",
32
            $rowInfo['row'],
33
            $colMic,
34
            $colMac,
35
            $height,
36
            $irwMac,
37
            $reserved,
38
            $this->getGrBit($rowInfo['format'], $rowInfo['hidden'], $level),
39
            $this->xf($rowInfo['format'])
40
        );
41
42
        return $this->getFullRecord($data);
43
    }
44
45
    /**
46
     * Get the options flags. fUnsynced is used to show that the font and row
47
     * heights are not compatible. This is usually the case for WriteExcel.
48
     * The collapsed flag 0x10 doesn't seem to be used to indicate that a row
49
     * is collapsed. Instead it is used to indicate that the previous row is
50
     * collapsed. The zero height flag, 0x20, is used to collapse a row.
51
     *
52
     * @param $format
53
     * @param $hidden
54
     * @param $level
55
     *
56
     * @return int
57
     */
58
    protected function getGrBit($format, $hidden, $level)
59
    {
60
        $grbit = 0x0000;
61
        $grbit |= $level;
62
63
        if ($hidden) {
64
            $grbit |= 0x0020;
65
        }
66
67
        $grbit |= 0x0040; // fUnsynced
68
69
        if ($format) {
70
            $grbit |= 0x0080;
71
        }
72
73
        $grbit |= 0x0100;
74
75
        return $grbit;
76
    }
77
}
78