Failed Conditions
Pull Request — develop_3.0 (#434)
by Hura
03:16
created

Worksheet   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 105
ccs 20
cts 28
cp 0.7143
rs 10
c 0
b 0
f 0

10 Methods

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