Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
Rewrote some code to be less complex
Browse files Browse the repository at this point in the history
  • Loading branch information
sstok committed Sep 22, 2016
1 parent 13e60ce commit c7a7dae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/Column/ColumnTypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public function getType($name): ResolvedColumnTypeInterface

if (!$type) {
// Support fully-qualified class names.
if (class_exists($name) && in_array(ColumnTypeInterface::class, class_implements($name), true)) {
$type = new $name();
} else {
if (!class_exists($name) || !in_array(ColumnTypeInterface::class, class_implements($name), true)) {
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
}

$type = new $name();
}

$this->types[$name] = $this->resolveType($type);
Expand Down
11 changes: 3 additions & 8 deletions src/Column/ResolvedColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,24 @@ public function buildType(ColumnInterface $config, array $options)
public function createColumn(string $name, array $options = []): ColumnInterface
{
$options = $this->getOptionsResolver()->resolve($options);
$builder = $this->newColumn($name, $options);

return $builder;
return $this->newColumn($name, $options);
}

/**
* {inheritdoc}.
*/
public function createHeaderView(ColumnInterface $column, DatagridView $datagrid): HeaderView
{
$view = new HeaderView($column, $datagrid, $column->getOption('label'));

return $view;
return new HeaderView($column, $datagrid, $column->getOption('label'));
}

/**
* {inheritdoc}.
*/
public function createCellView(ColumnInterface $column, DatagridView $datagrid): CellView
{
$view = new CellView($column, $datagrid);

return $view;
return new CellView($column, $datagrid);
}

/**
Expand Down

0 comments on commit c7a7dae

Please sign in to comment.