Completed
Pull Request — master (#557)
by Adrien
03:10
created

Worksheet::getMaxNumColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Entity;
4
5
/**
6
 * Class Worksheet
7
 * Entity describing a Worksheet
8
 */
9
class Worksheet
10
{
11
    /** @var string Path to the XML file that will contain the sheet data */
12
    private $filePath;
13
14
    /** @var resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
15
    private $filePointer;
16
17
    /** @var Sheet The "external" sheet */
18
    private $externalSheet;
19
20
    /** @var int Maximum number of columns among all the written rows */
21
    private $maxNumColumns;
22
23
    /** @var int Index of the last written row */
24
    private $lastWrittenRowIndex;
25
26
    /**
27
     * Worksheet constructor.
28
     *
29
     * @param string $worksheetFilePath
30
     * @param Sheet $externalSheet
31
     */
32 77
    public function __construct($worksheetFilePath, Sheet $externalSheet)
33
    {
34 77
        $this->filePath = $worksheetFilePath;
35 77
        $this->filePointer = null;
36 77
        $this->externalSheet = $externalSheet;
37 77
        $this->maxNumColumns = 0;
38 77
        $this->lastWrittenRowIndex = 0;
39 77
    }
40
41
    /**
42
     * @return string
43
     */
44 77
    public function getFilePath()
45
    {
46 77
        return $this->filePath;
47
    }
48
49
    /**
50
     * @return resource
51
     */
52 70
    public function getFilePointer()
53
    {
54 70
        return $this->filePointer;
55
    }
56
57
    /**
58
     * @param resource $filePointer
59
     */
60 77
    public function setFilePointer($filePointer)
61
    {
62 77
        $this->filePointer = $filePointer;
63 77
    }
64
65
    /**
66
     * @return Sheet
67
     */
68 72
    public function getExternalSheet()
69
    {
70 72
        return $this->externalSheet;
71
    }
72
73
    /**
74
     * @return int
75
     */
76 65
    public function getMaxNumColumns()
77
    {
78 65
        return $this->maxNumColumns;
79
    }
80
81
    /**
82
     * @param int $maxNumColumns
83
     */
84 61
    public function setMaxNumColumns($maxNumColumns)
85
    {
86 61
        $this->maxNumColumns = $maxNumColumns;
87 61
    }
88
89
    /**
90
     * @return int
91
     */
92 63
    public function getLastWrittenRowIndex()
93
    {
94 63
        return $this->lastWrittenRowIndex;
95
    }
96
97
    /**
98
     * @param int $lastWrittenRowIndex
99
     */
100 61
    public function setLastWrittenRowIndex($lastWrittenRowIndex)
101
    {
102 61
        $this->lastWrittenRowIndex = $lastWrittenRowIndex;
103 61
    }
104
105
    /**
106
     * @return int The ID of the worksheet
107
     */
108 70
    public function getId()
109
    {
110
        // sheet index is zero-based, while ID is 1-based
111 70
        return $this->externalSheet->getIndex() + 1;
112
    }
113
}
114