1 | <?php |
||
24 | abstract class WorkbookManagerAbstract implements WorkbookManagerInterface |
||
25 | { |
||
26 | /** @var Workbook The workbook to manage */ |
||
27 | protected $workbook; |
||
28 | |||
29 | /** @var OptionsManagerInterface */ |
||
30 | protected $optionManager; |
||
31 | |||
32 | /** @var WorksheetManagerInterface */ |
||
33 | protected $worksheetManager; |
||
34 | |||
35 | /** @var StyleHelperInterface */ |
||
36 | protected $styleHelper; |
||
37 | |||
38 | /** @var FileSystemWithRootFolderHelperInterface Helper to perform file system operations */ |
||
39 | protected $fileSystemHelper; |
||
40 | |||
41 | /** @var EntityFactory Factory to create entities */ |
||
42 | private $entityFactory; |
||
43 | |||
44 | /** @var Worksheet The worksheet where data will be written to */ |
||
45 | protected $currentWorksheet; |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @param Workbook $workbook |
||
50 | * @param OptionsManagerInterface $optionsManager |
||
51 | * @param WorksheetManagerInterface $worksheetManager |
||
52 | * @param StyleHelperInterface $styleHelper |
||
53 | * @param FileSystemWithRootFolderHelperInterface $fileSystemHelper |
||
54 | * @param EntityFactory $entityFactory |
||
55 | */ |
||
56 | 89 | public function __construct( |
|
71 | |||
72 | /** |
||
73 | * @return int Maximum number of rows/columns a sheet can contain |
||
74 | */ |
||
75 | abstract protected function getMaxRowsPerWorksheet(); |
||
76 | |||
77 | /** |
||
78 | * @param Sheet $sheet |
||
79 | * @return string The file path where the data for the given sheet will be stored |
||
80 | */ |
||
81 | abstract protected function getWorksheetFilePath(Sheet $sheet); |
||
82 | |||
83 | /** |
||
84 | * @return Workbook |
||
85 | */ |
||
86 | 70 | public function getWorkbook() |
|
90 | |||
91 | /** |
||
92 | * Creates a new sheet in the workbook and make it the current sheet. |
||
93 | * The writing will resume where it stopped (i.e. data won't be truncated). |
||
94 | * |
||
95 | * @return Worksheet The created sheet |
||
96 | * @throws IOException If unable to open the sheet for writing |
||
97 | */ |
||
98 | 89 | public function addNewSheetAndMakeItCurrent() |
|
105 | |||
106 | /** |
||
107 | * Creates a new sheet in the workbook. The current sheet remains unchanged. |
||
108 | * |
||
109 | * @return Worksheet The created sheet |
||
110 | * @throws \Box\Spout\Common\Exception\IOException If unable to open the sheet for writing |
||
111 | */ |
||
112 | 89 | private function addNewSheet() |
|
129 | |||
130 | /** |
||
131 | * @return Worksheet[] All the workbook's sheets |
||
132 | */ |
||
133 | 89 | public function getWorksheets() |
|
137 | |||
138 | /** |
||
139 | * Returns the current sheet |
||
140 | * |
||
141 | * @return Worksheet The current sheet |
||
142 | */ |
||
143 | 70 | public function getCurrentWorksheet() |
|
147 | |||
148 | /** |
||
149 | * Sets the given sheet as the current one. New data will be written to this sheet. |
||
150 | * The writing will resume where it stopped (i.e. data won't be truncated). |
||
151 | * |
||
152 | * @param Sheet $sheet The "external" sheet to set as current |
||
153 | * @return void |
||
154 | * @throws SheetNotFoundException If the given sheet does not exist in the workbook |
||
155 | */ |
||
156 | 4 | public function setCurrentSheet(Sheet $sheet) |
|
165 | |||
166 | /** |
||
167 | * @param Worksheet $worksheet |
||
168 | * @return void |
||
169 | */ |
||
170 | 89 | private function setCurrentWorksheet($worksheet) |
|
174 | |||
175 | /** |
||
176 | * Returns the worksheet associated to the given external sheet. |
||
177 | * |
||
178 | * @param Sheet $sheet |
||
179 | * @return Worksheet|null The worksheet associated to the given external sheet or null if not found. |
||
180 | */ |
||
181 | 4 | private function getWorksheetFromExternalSheet($sheet) |
|
194 | |||
195 | /** |
||
196 | * Adds a row to the current sheet. |
||
197 | * If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination |
||
198 | * with the creation of new worksheets if one worksheet has reached its maximum capicity. |
||
199 | * |
||
200 | * @param Row $row The row to added |
||
201 | * @return void |
||
202 | * @throws IOException If trying to create a new sheet and unable to open the sheet for writing |
||
203 | * @throws WriterException If unable to write data |
||
204 | */ |
||
205 | 64 | public function addRowToCurrentWorksheet(Row $row) |
|
224 | |||
225 | /** |
||
226 | * @return bool Whether the current worksheet has reached the maximum number of rows per sheet. |
||
227 | */ |
||
228 | 64 | private function hasCurrentWorkseetReachedMaxRows() |
|
233 | |||
234 | /** |
||
235 | * Adds data with the given style to the given sheet. |
||
236 | * |
||
237 | * @param Worksheet $worksheet Worksheet to write the row to |
||
238 | * @param array $dataRow Array containing data to be written. Cannot be empty. |
||
|
|||
239 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
240 | * @return void |
||
241 | * @throws WriterException If unable to write data |
||
242 | */ |
||
243 | 64 | private function addRowWithStyleToWorksheet(Worksheet $worksheet, Row $row) |
|
252 | |||
253 | /** |
||
254 | * Closes the workbook and all its associated sheets. |
||
255 | * All the necessary files are written to disk and zipped together to create the final file. |
||
256 | * All the temporary files are then deleted. |
||
257 | * |
||
258 | * @param resource $finalFilePointer Pointer to the spreadsheet that will be created |
||
259 | * @return void |
||
260 | */ |
||
261 | 70 | public function close($finalFilePointer) |
|
268 | |||
269 | /** |
||
270 | * Closes custom objects that are still opened |
||
271 | * |
||
272 | * @return void |
||
273 | */ |
||
274 | 34 | protected function closeRemainingObjects() |
|
278 | |||
279 | /** |
||
280 | * Writes all the necessary files to disk and zip them together to create the final file. |
||
281 | * |
||
282 | * @param resource $finalFilePointer Pointer to the spreadsheet that will be created |
||
283 | * @return void |
||
284 | */ |
||
285 | abstract protected function writeAllFilesToDiskAndZipThem($finalFilePointer); |
||
286 | |||
287 | /** |
||
288 | * Closes all workbook's associated sheets. |
||
289 | * |
||
290 | * @return void |
||
291 | */ |
||
292 | 70 | private function closeAllWorksheets() |
|
300 | |||
301 | /** |
||
302 | * Deletes the root folder created in the temp folder and all its contents. |
||
303 | * |
||
304 | * @return void |
||
305 | */ |
||
306 | 70 | protected function cleanupTempFolder() |
|
311 | } |
||
312 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.