number-to-words
number-to-words copied to clipboard
Make NumberTransformerBuilder injectable
First, thank you for your work.
If you use one of the supplied transformers (for example, GermanCurrencyTransformer), there is no way to modify the NumberTransformerBuilder. In my case, I need to customize the "withWordsSeparatedBy()" method, but the rest should stay the same.
Perhaps the CurrencyTransformer interface could get a "getTransformerBuilder()" method so that I can override this method to provde a custom provider in a child class.
Here is a simple example:
class CustomizedGermanCurrencyTransformer extends GermanCurrencyTransformer {
/**
* Overrides the default transformer builder to modify builder options
*
* @return \NumberToWords\NumberTransformer\NumberTransformer
*/
public function getTransformerBuilder()
{
return $numberTransformer = (new NumberTransformerBuilder())
->withDictionary($dictionary)
->withWordsSeparatedBy('')
->transformNumbersBySplittingIntoPowerAwareTriplets($numberToTripletsConverter, $tripletTransformer)
->inflectExponentByNumbers($exponentInflector)
->build();
}
}