Formula   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B getData() 0 26 1
1
<?php
2
namespace Xls\Record;
3
4
class Formula extends AbstractRecord
5
{
6
    const NAME = 'FORMULA';
7
    const ID = 0x0006;
8
9
    /**
10
     * @param $row
11
     * @param $col
12
     * @param string $formula Formula in reverse polish format
13
     * @param $format
14
     *
15
     * @return string
16
     * @throws \Exception
17
     */
18
    public function getData($row, $col, $formula, $format)
19
    {
20
        // Excel normally stores the last calculated value of the formula in $num.
21
        // Clearly we are not in a position to calculate this a priori. Instead
22
        // we set $num to zero and set the option flags in $grbit to ensure
23
        // automatic calculation of the formula when the file is opened.
24
        $num = 0x00; // Current value of formula
25
        $grbit = 0x03; // Option flags
26
        $unknown = 0x0000; // Must be zero
27
28
        $formlen = strlen($formula);
29
30
        $data = pack(
31
            "vvvdvVv",
32
            $row,
33
            $col,
34
            $this->xf($format),
35
            $num,
36
            $grbit,
37
            $unknown,
38
            $formlen
39
        );
40
        $data .= $formula;
41
42
        return $this->getFullRecord($data);
43
    }
44
}
45