See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401]
1 <?php 2 3 namespace Box\Spout\Reader\Common\Manager; 4 5 use Box\Spout\Common\Entity\Row; 6 use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface; 7 8 /** 9 * Class RowManager 10 */ 11 class RowManager 12 { 13 /** @var InternalEntityFactoryInterface Factory to create entities */ 14 private $entityFactory; 15 16 /** 17 * @param InternalEntityFactoryInterface $entityFactory Factory to create entities 18 */ 19 public function __construct(InternalEntityFactoryInterface $entityFactory) 20 { 21 $this->entityFactory = $entityFactory; 22 } 23 24 /** 25 * Detect whether a row is considered empty. 26 * An empty row has all of its cells empty. 27 * 28 * @param Row $row 29 * @return bool 30 */ 31 public function isEmpty(Row $row) 32 { 33 foreach ($row->getCells() as $cell) { 34 if (!$cell->isEmpty()) { 35 return false; 36 } 37 } 38 39 return true; 40 } 41 42 /** 43 * Fills the missing indexes of a row with empty cells. 44 * 45 * @param Row $row 46 * @return Row 47 */ 48 public function fillMissingIndexesWithEmptyCells(Row $row) 49 { 50 if ($row->getNumCells() === 0) { 51 return $row; 52 } 53 54 $rowCells = $row->getCells(); 55 $maxCellIndex = max(array_keys($rowCells)); 56 57 for ($cellIndex = 0; $cellIndex < $maxCellIndex; $cellIndex++) { 58 if (!isset($rowCells[$cellIndex])) { 59 $row->setCellAtIndex($this->entityFactory->createCell(''), $cellIndex); 60 } 61 } 62 63 return $row; 64 } 65 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body