AbstractRecord::xf()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
namespace Xls\Record;
3
4
use Xls\Format as XlsFormat;
5
6
abstract class AbstractRecord
7
{
8
    const ID = 0x00;
9
10
    /**
11
     * Returns record header data ready for writing
12
     * @param int $length
13
     * @return string
14
     */
15
    public static function getHeader($length = 0)
16
    {
17
        return pack("vv", static::ID, $length);
18
    }
19
20
    /**
21
     * @param XlsFormat|null $format
22
     *
23
     * @return int
24
     */
25
    protected function xf($format)
26
    {
27
        return (is_object($format)) ? $format->getXfIndex() : 0x0F;
28
    }
29
30
    /**
31
     * returns full record data: header + data
32
     * @param $data
33
     *
34
     * @return string
35
     */
36
    protected function getFullRecord($data = '')
37
    {
38
        return $this->getHeader(strlen($data)) . $data;
39
    }
40
41
    /**
42
     * @param string $type
43
     * @param array $params
44
     *
45
     * @return mixed
46
     */
47
    protected function getSubRecord($type, array $params = array())
48
    {
49
        $callable = array("\\Xls\\Subrecord\\$type", 'getData');
50
51
        return call_user_func_array($callable, $params);
52
    }
53
}
54