| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Box\Spout\Writer\Common\Creator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Box\Spout\Writer\Common\Entity\Row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Box\Spout\Writer\Common\Entity\Cell; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Box\Spout\Writer\Common\Entity\Sheet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Box\Spout\Writer\Common\Entity\Style\Style; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Box\Spout\Writer\Common\Entity\Workbook; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Box\Spout\Writer\Common\Entity\Worksheet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Box\Spout\Writer\Common\Manager\RowManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Box\Spout\Writer\Common\Manager\SheetManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Box\Spout\Writer\Common\Manager\Style\StyleMerger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Class EntityFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * Factory to create entities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | class EntityFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @return Workbook | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 84 |  |     public function createWorkbook() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 84 |  |         return new Workbook(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param string $worksheetFilePath | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @param Sheet $externalSheet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @return Worksheet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 84 |  |     public function createWorksheet($worksheetFilePath, Sheet $externalSheet) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 84 |  |         return new Worksheet($worksheetFilePath, $externalSheet); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @param string $associatedWorkbookId ID of the sheet's associated workbook | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param SheetManager $sheetManager To manage sheets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @return Sheet | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 45 | 84 |  |     public function createSheet($sheetIndex, $associatedWorkbookId, $sheetManager) | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 47 | 84 |  |         return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager); | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @param mixed $cellValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @return Cell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     public static function createCell($cellValue) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         return new Cell($cellValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @return \ZipArchive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 69 |  |     public function createZipArchive() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 69 |  |         return new \ZipArchive(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @param array $cells | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param Style|null $style | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @return Row | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 80 |  |     public static function createRow(array $cells, Style $style = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 80 |  |         $styleMerger = new StyleMerger(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 80 |  |         $rowManager = new RowManager($styleMerger); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 80 |  |         return new Row($cells, $style, $rowManager); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 79 |  |  |  |