Completed
Pull Request — master (#715)
by
unknown
04:32
created

Worksheet::setSheetDataStarted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
    /** @var bool has the sheet data header been written */
27
    private $sheetDataStarted = false;
28
29
    /**
30
     * Worksheet constructor.
31
     *
32
     * @param string $worksheetFilePath
33
     * @param Sheet $externalSheet
34
     */
35 93
    public function __construct($worksheetFilePath, Sheet $externalSheet)
36
    {
37 93
        $this->filePath = $worksheetFilePath;
38 93
        $this->filePointer = null;
39 93
        $this->externalSheet = $externalSheet;
40 93
        $this->maxNumColumns = 0;
41 93
        $this->lastWrittenRowIndex = 0;
42 93
        $this->sheetDataStarted = false;
43 93
    }
44
45
    /**
46
     * @return string
47
     */
48 93
    public function getFilePath()
49
    {
50 93
        return $this->filePath;
51
    }
52
53
    /**
54
     * @return resource
55
     */
56 86
    public function getFilePointer()
57
    {
58 86
        return $this->filePointer;
59
    }
60
61
    /**
62
     * @param resource $filePointer
63
     */
64 93
    public function setFilePointer($filePointer)
65
    {
66 93
        $this->filePointer = $filePointer;
67 93
    }
68
69
    /**
70
     * @return Sheet
71
     */
72 88
    public function getExternalSheet()
73
    {
74 88
        return $this->externalSheet;
75
    }
76
77
    /**
78
     * @return int
79
     */
80 82
    public function getMaxNumColumns()
81
    {
82 82
        return $this->maxNumColumns;
83
    }
84
85
    /**
86
     * @param int $maxNumColumns
87
     */
88 79
    public function setMaxNumColumns($maxNumColumns)
89
    {
90 79
        $this->maxNumColumns = $maxNumColumns;
91 79
    }
92
93
    /**
94
     * @return int
95
     */
96 81
    public function getLastWrittenRowIndex()
97
    {
98 81
        return $this->lastWrittenRowIndex;
99
    }
100
101
    /**
102
     * @param int $lastWrittenRowIndex
103
     */
104 79
    public function setLastWrittenRowIndex($lastWrittenRowIndex)
105
    {
106 79
        $this->lastWrittenRowIndex = $lastWrittenRowIndex;
107 79
    }
108
109
    /**
110
     * @return int The ID of the worksheet
111
     */
112 86
    public function getId()
113
    {
114
        // sheet index is zero-based, while ID is 1-based
115 86
        return $this->externalSheet->getIndex() + 1;
116
    }
117
118
    /**
119
     * @return bool
120
     */
121 45
    public function getSheetDataStarted()
122
    {
123 45
        return $this->sheetDataStarted;
124
    }
125
126
    /**
127
     * @param bool $sheetDataStarted
128
     */
129 45
    public function setSheetDataStarted($sheetDataStarted)
130
    {
131 45
        $this->sheetDataStarted = $sheetDataStarted;
132 45
    }
133
}
134