Re: Proposal: Services_ExchangeRates
| From: | Marshall Roch | Date: | Fri, 29 Aug 2003 04:16:56 +0000 |
| Subject: | Re: Proposal: Services_ExchangeRates | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20796@lists.php.net to get a copy of this message | ||
Greg Beaver wrote:
whoops.. fixed. :) Also, why can't you multiply like that? That's what caused the errors you mentioned.var $_cacheLenghtRates = 60 * 60 * 1; // sec/min * min/hr * hrs$_cacheLenghtRates^^
retrieveData() will give PHP warnings if the driver is missing, perhaps you could encapsulate the include_once() call like so:$classname won't exist until after you include the file, so it has to be the other way around. I supressed the PHP warning (the dreaded @include_once()) and added a PEAR error.function retrieveData($source, $cacheLenth) { $classname = "Services_Exchange_$source"; if (!class_exists($classname)) { include_once("Services/Exchange/$source.php"); return PEAR::raiseError("No driver exists for the source ${source}... aborting.", true); } $class = new $classname($cacheLength);return $class->retrieve(); }You'll still get the PHP warning, but only for typos when a warning is appropriate.
I'd like to see error codes used before the package is accepted, it will give the package a wider audience.Ok, I think that's done. I've never used PEAR error handling, so I'm only marginally sure that it's right. I haven't been able to figure out how to get it to display errors to the user...
I'd also recommend using a system similar to Cache_Lite - include PEAR.php if you have an error, and otherwise, don't. Some users will like the speed difference (just a recommendation).Done. This is good, because the script is already fairly slow when it has to update the cache.
A more serious problem, the example displays:
Parse error: parse error, expecting ','' or ';'' in /home/exclupen/public_html/misc/pear/Services/ExchangeRates.php on line 64
Fatal error: Cannot instantiate non-existent class: services_exchangerates in /home/exclupen/public_html/misc/pear/Services/ExchangeRates/docs/example.php on line 37
Fixed. The example works now.
If these changes make the package get a +1 from you, I'm only looking for one more.
Thanks, everyone, for your comments!
--
Marshall Roch