[Locale] added static constructor
This commit is contained in:
parent
69b0e09d6a
commit
b58e25cc83
@ -234,6 +234,25 @@ class StubNumberFormatter
|
|||||||
$this->style = $style;
|
$this->style = $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static constructor
|
||||||
|
*
|
||||||
|
* @param string $locale The locale code
|
||||||
|
* @param int $style Style of the formatting, one of the format style constants
|
||||||
|
* @param string $pattern A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
|
||||||
|
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
|
||||||
|
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
|
||||||
|
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
|
||||||
|
* @see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details
|
||||||
|
* @throws MethodArgumentValueNotImplementedException When $locale different than 'en' is passed
|
||||||
|
* @throws MethodArgumentValueNotImplementedException When the $style is not supported
|
||||||
|
* @throws MethodArgumentNotImplementedException When the pattern value is different than null
|
||||||
|
*/
|
||||||
|
public static function create($locale = 'en', $style = null, $pattern = null)
|
||||||
|
{
|
||||||
|
return new self($locale, $style, $pattern);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a currency value
|
* Format a currency value
|
||||||
*
|
*
|
||||||
|
@ -65,6 +65,20 @@ class StubNumberFormatterTest extends LocaleTestCase
|
|||||||
$ret = $formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, null);
|
$ret = $formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateStub()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
'Symfony\Component\Locale\Stub\StubNumberFormatter',
|
||||||
|
StubNumberFormatter::create('en', StubNumberFormatter::DECIMAL)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreateIntl()
|
||||||
|
{
|
||||||
|
$this->skipIfIntlExtensionIsNotLoaded();
|
||||||
|
$this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider formatCurrencyWithDecimalStyleProvider
|
* @dataProvider formatCurrencyWithDecimalStyleProvider
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user