Re: Name for converter of units/currency

From: Date: Fri, 19 Jan 2001 09:41:30 +0000
Subject: Re: Name for converter of units/currency
References: 1 2  Groups: php.pear 
Request: Send a blank email to php-pear+get-1112@lists.php.net to get a copy of this message
Hello David, On Fri, Jan 19, 2001 at 01:36 +0000, David Croft wrote: > > > Has anyone considered, in this discussion, the fundamental difference > between converting units of *measurement* (which have fixed > conversion ratios) and units of *currency* (for which the conversion > ratios are variable). > > How are you intending to find the conversion ratio? If it's to be passed > into the function by the caller, then I would suggest that the class is > unnecessary. $dollars = $sterling / $conversion_ratio is not something > that needs to be encapsulated. If it is to be located from some outside > service, we need to talk about the reliability and general case for this. > If it's to be stored in a database, there are a plethora of implementation > issues. My vote would be to remove currency conversion entirely from PEAR. I'd suggest that currency convertor could switch between various conversions dependent on some argument. Recently, I programmed a site that needed to display monetary values in US dollars or roubles, accordingly to user's preference. So, I designed a class that behaves like this: $conv = new CurrencyConvertor($conv_params); // pass a ratio etc. $display_currency = 'USD'; $priceUSD = $conv->convert($price, 'USD', $display_currency); // the value returned unchanged $priceRUB = $conv->convert($price, 'RUB', $display_currency); // scaled through the conversion ratio -- Stay tuned, MhZ mailto:mookid@sigent.ru ----------- The problem with any unwritten law is that you don't know where to go to erase it. -- Glaser and Way

« previous php.pear (#1112) next »