Class PHP et gestion des erreurs
Bonjour,
je cherche à gérer les erreurs d'une class PHP utilisant CuRL, cette class utilise 3 fonctions liées init(), sendFirstForm(), sendSecondForm() dont je test le résultat via des instructions IF imbriquées (voir plus bas).
Est ce que la logique est bonne ?
Merci pour vos conseils
Cdlt
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| class Sender {
public $error;
public function __construct() {
$this->error = NULL;
}
public function send() {
if($this->init() === TRUE)
{
if($this->sendFirstForm() === TRUE)
{
if($this->sendSecondForm() === TRUE)
{
}
}
}
}
public function init() {
// CuRL : traitement récupération cookie
$ch = ...
if(curl_errno($ch))
{
$this->error = 'CuRL Error : ' . curl_error($ch);
return $this->error;
}
}
public function sendFirstForm() {
// CuRL : envoi premier formulaire
$ch = ...
if(curl_errno($ch))
{
$this->error = 'CuRL Error : ' . curl_error($ch);
return $this->error;
}
}
public function sendSecondForm() {
// CuRL : envoi deuxieme formulaire
$ch = ...
if(curl_errno($ch))
{
$this->error = 'CuRL Error : ' . curl_error($ch);
return $this->error;
}
}
} |