AbstractRecord   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 12
Bugs 2 Features 2
Metric Value
wmc 5
c 12
b 2
f 2
lcom 0
cbo 1
dl 0
loc 48
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeader() 0 4 1
A xf() 0 4 2
A getFullRecord() 0 4 1
A getSubRecord() 0 6 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