Skip to content

Commit 21784ce

Browse files
committed
[Console] make it possible to pass a style directly to Table::setStyle()
1 parent 14caaec commit 21784ce

File tree

1 file changed

+6
-6
lines changed
  • src/Symfony/Component/Console/Helper

1 file changed

+6
-6
lines changed

src/Symfony/Component/Console/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy