[PEPr] Comment on Networking::AsteriskManager
| From: | David Jean Louis | Date: | Sat, 22 Mar 2008 08:33:11 +0000 |
| Subject: | [PEPr] Comment on Networking::AsteriskManager | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-49492@lists.php.net to get a copy of this message | ||
David Jean Louis (http://pear.php.net/user/izi) has commented on the proposal for
Networking::AsteriskManager.
Comment:
I second Philippe's comments, also:
* It seems weird to me to connect to the server in the constructor, I
would use a connect() method or use some kind of lazy connection system so
the class can be instanciated without connecting immediately to the
server;
* I would improve error checking and use exceptions instead of just
returning "false" in your method, so you can provide meaningful error
messages;
* I would modifiy the __construct() signature to receive a $params array
(if you add params later you will not have to modify the signature and
break the BC) and also move $username, $password in the login method
(there's no need to store them in the class), example:
try {
$asterix = new Net_AsterixManager(array(
'server' => 'example.com',
'port' => 5038
));
$asterix->login('joe', 'secret');
$asterix->command('somecommand');
// ...
} catch (Exception $exc) {
// do something...
}
* I don't know asterix but you should do some validity checks in your
command() method (ie: store all authorized commands in a an array and throw
an exception if a command is not valid);
Proposal information:
http://pear.php.net/pepr/pepr-proposal-show.php?id=543
--
Sent by PEPr, the automatic proposal system at http://pear.php.net