[Console] Extract the OutputFormatter's regular expression into the inteface.

This commit is contained in:
Laszlo Korte 2011-06-23 18:14:54 +02:00
parent bc2f9479e3
commit 9a829242fb
2 changed files with 6 additions and 1 deletions

View File

@ -125,7 +125,7 @@ class OutputFormatter implements OutputFormatterInterface
*/ */
public function format($message) public function format($message)
{ {
return preg_replace_callback('#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is', array($this, 'replaceStyle'), $message); return preg_replace_callback(OutputFormatterStyleInterface::FORMAT_PATTERN, array($this, 'replaceStyle'), $message);
} }
/** /**

View File

@ -20,6 +20,11 @@ namespace Symfony\Component\Console\Formatter;
*/ */
interface OutputFormatterInterface interface OutputFormatterInterface
{ {
/**
* The pattern to phrase the format.
*/
const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is';
/** /**
* Sets the decorated flag. * Sets the decorated flag.
* *