added Row::getCellAtIndex method

This commit is contained in:
madflow 2018-02-08 12:24:24 +01:00 committed by Adrien Loison
parent 21e0e9e6b1
commit 29cf6245a1
2 changed files with 22 additions and 2 deletions

View File

@ -54,8 +54,7 @@ class Row
/**
* @param Cell $cell
* @param mixed $cellIndex
* @parma int $cellIndex
* @param int $cellIndex
* @return Row
*/
public function setCellAtIndex(Cell $cell, $cellIndex)
@ -65,6 +64,15 @@ class Row
return $this;
}
/**
* @param int $cellIndex
* @return Cell|null
*/
public function getCellAtIndex($cellIndex)
{
return isset($this->cells[$cellIndex]) ? $this->cells[$cellIndex] : null;
}
/**
* @param Cell $cell
* @return Row

View File

@ -70,6 +70,18 @@ class RowTest extends \PHPUnit\Framework\TestCase
$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
*/