Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chives committed Feb 9, 2021
1 parent 8ed12ed commit 798448c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/DataGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FSi\Component\DataGrid\Data\DataRowsetInterface;
use FSi\Component\DataGrid\Column\ColumnTypeInterface;
use FSi\Component\DataGrid\Column\HeaderViewInterface;
use InvalidArgumentException;
use RuntimeException;

class DataGridView implements DataGridViewInterface
Expand Down Expand Up @@ -42,15 +43,13 @@ class DataGridView implements DataGridViewInterface
* @param string $name
* @param ColumnTypeInterface[] $columns
* @param DataRowsetInterface $rowset
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct(string $name, array $columns, DataRowsetInterface $rowset)
{
foreach ($columns as $column) {
if (!$column instanceof ColumnTypeInterface) {
throw new \InvalidArgumentException(
'Column must implement FSi\Component\DataGrid\Column\ColumnTypeInterface'
);
throw new InvalidArgumentException(sprintf('Column must implement %s', ColumnTypeInterface::class));
}

$this->columns[$column->getName()] = $column;
Expand Down Expand Up @@ -97,7 +96,7 @@ public function getColumn(string $name): HeaderViewInterface
return $this->columnsHeaders[$name];
}

throw new \InvalidArgumentException(sprintf('Column "%s" does not exist in data grid.', $name));
throw new InvalidArgumentException(sprintf('Column "%s" does not exist in data grid.', $name));
}

public function getColumns(): array
Expand All @@ -113,7 +112,7 @@ public function clearColumns(): void
public function addColumn(HeaderViewInterface $column): void
{
if (!array_key_exists($column->getName(), $this->columns)) {
throw new \InvalidArgumentException(sprintf(
throw new InvalidArgumentException(sprintf(
'Column with name "%s" was never registred in datagrid "%s"',
$column->getName(),
$this->getName()
Expand All @@ -129,13 +128,11 @@ public function setColumns(array $columns): void

foreach ($columns as $column) {
if (!$column instanceof HeaderViewInterface) {
throw new \InvalidArgumentException(
'Column must implement FSi\Component\DataGrid\Column\HeaderViewInterface'
);
throw new InvalidArgumentException(sprintf('Column must implement %s', HeaderViewInterface::class));
}

if (!array_key_exists($column->getName(), $this->columns)) {
throw new \InvalidArgumentException(sprintf(
throw new InvalidArgumentException(sprintf(
'Column with name "%s" was never registred in datagrid "%s"',
$column->getName(),
$this->getName()
Expand Down Expand Up @@ -202,7 +199,7 @@ public function offsetGet($offset)
return new DataGridRowView($this, $this->getOriginColumns(), $this->rowset[$offset], $offset);
}

throw new \InvalidArgumentException(sprintf('Row "%s" does not exist in rowset.', $offset));
throw new InvalidArgumentException(sprintf('Row "%s" does not exist in rowset.', $offset));
}

public function offsetSet($offset, $value): void
Expand Down

0 comments on commit 798448c

Please sign in to comment.