Example how to make better code
Sat Jan 9 2010
OK, but not great:
public static function factory(){
if(extension_loaded('mailparse')){
$objMailParser
= new clsMessageParser2();
}
else{
/**
* We
don't have an implementation based on Mail_mimeDecode
* so for
now we can't do anything without mailparse extension
*/
throw new
MailParserException('This class depends in "mailparse" extension of php and
your version of php does not have "mailparse"
installed');
}
return $objMailParser;
} // end factory
/////////////////////////
Better:
public static function factory(){
if(extension_loaded('mailparse')){
$objMailParser
= new clsMessageParser2();
}
/**
* We don't have an
implementation based on Mail_mimeDecode
* so for now we can't do
anything without mailparse extension
*/
throw new
MailParserException('This class depends in "mailparse" extension of php and
your version of php does not have "mailparse" installed');
return $objMailParser;
} // end factory
/////////////////////
Best:
public static function factory(){
/**
* We don't have an
implementation based on Mail_mimeDecode
* so for now we can't do
anything without mailparse extension
*/
if(!extension_loaded('mailparse')){
throw new
MailParserException('This class depends in "mailparse" extension of php and
your version of php does not have "mailparse"
installed');
}
$objMailParser = new
clsMessageParser2();
return $objMailParser;
} // end factory