added Row::getCellAtIndex method

This commit is contained in:
madflow authored and Adrien Loison committed 2018-02-14 21:32:10 +01:00
1 parent 21e0e9e6b1
commit 29cf6245a1
2 files changed
+22 -2

No files matched your search

+10 -2
View File
@@ -54,8 +54,7 @@ class Row
/** /**
* @param Cell $cell * @param Cell $cell
* @param mixed $cellIndex * @param int $cellIndex
* @parma int $cellIndex
* @return Row * @return Row
*/ */
public function setCellAtIndex(Cell $cell, $cellIndex) public function setCellAtIndex(Cell $cell, $cellIndex)
@@ -65,6 +64,15 @@ class Row
return $this; return $this;
} }
/**
* @param int $cellIndex
* @return Cell|null
*/
public function getCellAtIndex($cellIndex)
{
return isset($this->cells[$cellIndex]) ? $this->cells[$cellIndex] : null;
}
/** /**
* @param Cell $cell * @param Cell $cell
* @return Row * @return Row
+12
View File
@@ -70,6 +70,18 @@ class RowTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(2, $row->getNumCells()); $this->assertEquals(2, $row->getNumCells());
} }
/**
* @return void
*/
public function testGetCellAtIndex()
{
$row = new Row([], null);
$cellMock = $this->getCellMock();
$row->setCellAtIndex($cellMock, 3);
$this->assertEquals($cellMock, $row->getCellAtIndex(3));
$this->assertNull($row->getCellAtIndex(10));
}
/** /**
* @return void * @return void
*/ */