Skip to content

Commit c4f8f7a

Browse files
committed
[Console] make it possible to pass a style directly to Table::setStyle()
1 parent 143130b commit c4f8f7a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Helper/Table.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ public static function getStyleDefinition($name)
110110
/**
111111
* Sets table style.
112112
*
113-
* @param string $name The style name
113+
* @param TableStyle|string $name The style name or a TableStyle instance
114114
*
115115
* @return Table
116116
*/
117117
public function setStyle($name)
118118
{
119-
if (isset(self::$styles[$name])) {
119+
if ($name instanceof TableStyle) {
120+
$this->style = $name;
121+
} elseif (isset(self::$styles[$name])) {
120122
$this->style = self::$styles[$name];
121-
122-
return $this;
123+
} else {
124+
throw new \InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
123125
}
124-
125-
throw new \InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
126126
}
127127

128128
/**

0 commit comments

Comments
 (0)