Differences Between: [Versions 310 and 400] [Versions 39 and 400]
1 <?php 2 3 namespace Box\Spout\Reader\CSV\Creator; 4 5 use Box\Spout\Common\Creator\HelperFactory; 6 use Box\Spout\Common\Entity\Cell; 7 use Box\Spout\Common\Entity\Row; 8 use Box\Spout\Common\Helper\GlobalFunctionsHelper; 9 use Box\Spout\Common\Manager\OptionsManagerInterface; 10 use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface; 11 use Box\Spout\Reader\CSV\RowIterator; 12 use Box\Spout\Reader\CSV\Sheet; 13 use Box\Spout\Reader\CSV\SheetIterator; 14 15 /** 16 * Class EntityFactory 17 * Factory to create entities 18 */ 19 class InternalEntityFactory implements InternalEntityFactoryInterface 20 { 21 /** @var HelperFactory */ 22 private $helperFactory; 23 24 /** 25 * @param HelperFactory $helperFactory 26 */ 27 public function __construct(HelperFactory $helperFactory) 28 { 29 $this->helperFactory = $helperFactory; 30 } 31 32 /** 33 * @param resource $filePointer Pointer to the CSV file to read 34 * @param OptionsManagerInterface $optionsManager 35 * @param GlobalFunctionsHelper $globalFunctionsHelper 36 * @return SheetIterator 37 */ 38 public function createSheetIterator($filePointer, $optionsManager, $globalFunctionsHelper) 39 { 40 $rowIterator = $this->createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper); 41 $sheet = $this->createSheet($rowIterator); 42 43 return new SheetIterator($sheet); 44 } 45 46 /** 47 * @param RowIterator $rowIterator 48 * @return Sheet 49 */ 50 private function createSheet($rowIterator) 51 { 52 return new Sheet($rowIterator); 53 } 54 55 /** 56 * @param resource $filePointer Pointer to the CSV file to read 57 * @param OptionsManagerInterface $optionsManager 58 * @param GlobalFunctionsHelper $globalFunctionsHelper 59 * @return RowIterator 60 */ 61 private function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper) 62 { 63 $encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper); 64 65 return new RowIterator($filePointer, $optionsManager, $encodingHelper, $this, $globalFunctionsHelper); 66 } 67 68 /** 69 * @param Cell[] $cells 70 * @return Row 71 */ 72 public function createRow(array $cells = []) 73 { 74 return new Row($cells, null); 75 } 76 77 /** 78 * @param mixed $cellValue 79 * @return Cell 80 */ 81 public function createCell($cellValue) 82 { 83 return new Cell($cellValue); 84 } 85 86 /** 87 * @param array $cellValues 88 * @return Row 89 */ 90 public function createRowFromArray(array $cellValues = []) 91 { 92 $cells = \array_map(function ($cellValue) { 93 return $this->createCell($cellValue); 94 }, $cellValues); 95 96 return $this->createRow($cells); 97 } 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body