osC_ErrorHandler Class Reference

Gestionnaire d'erreur. More...

Inherits SplSubject, and IteratorAggregate.

List of all members.

Public Member Functions

Static Public Member Functions

Protected Member Functions

Static Protected Attributes

Private Attributes


Detailed Description

Gestionnaire d'erreur.

Definition at line 36 of file osC_ErrorHandler.php.


Constructor & Destructor Documentation

osC_ErrorHandler::__construct (  )  [protected]

Definition at line 45 of file osC_ErrorHandler.php.

00045                                      {
00046       $this->_observers = new SplObjectStorage();
00047       $this->timer_start = PAGE_PARSE_START_TIME;
00048     }


Member Function Documentation

osC_ErrorHandler::__call ( funct,
args 
)

Definition at line 108 of file osC_ErrorHandler.php.

00109     {
00110         if (preg_match('#(att|det)ach(\w+)#', $funct, $matches)) {
00111             $meth     = $matches[1].'ach';
00112             $listener = strtolower($matches[2]);
00113             return $this->$meth(self::factory($listener, $args));
00114         }
00115         throw new BadMethodCallException("methode $funct inexistante");
00116     }

osC_ErrorHandler::attach ( SplObserver obs  ) 

Definition at line 97 of file osC_ErrorHandler.php.

00098     {
00099         $this->_observers->attach($obs);
00100         return $this;
00101     }

osC_ErrorHandler::detach ( SplObserver obs  ) 

Definition at line 103 of file osC_ErrorHandler.php.

00104     {
00105         $this->_observers->detach($obs);
00106         return $this;
00107     }

osC_ErrorHandler::error ( errno,
errstr,
errfile,
errline 
)

Definition at line 81 of file osC_ErrorHandler.php.

00081                                                              {
00082       if(error_reporting() == 0) {
00083           return;
00084               }
00085       $this->_errno   = $errno;
00086       $this->_errstr  = $errstr;
00087       $this->_errfile = $errfile;
00088       $this->_errline = $errline;
00089       $this->notify();
00090       return true;
00091   }

osC_ErrorHandler::factory ( listener,
array $  args = array() 
)

Definition at line 66 of file osC_ErrorHandler.php.

00066                                                             {
00067       $reflect = new ReflectionClass($listener);
00068       return $reflect->newInstanceArgs($args);
00069   }

osC_ErrorHandler::getError (  ) 

Definition at line 93 of file osC_ErrorHandler.php.

00093                              {
00094     return  $this->_errstr . ', ' . $this->_errfile . ', ' . $this->_errline;
00095   }

static osC_ErrorHandler::getInstance (  )  [static]

Definition at line 50 of file osC_ErrorHandler.php.

Referenced by resetInstance(), start(), and stop().

00051     {
00052         if(self::$_instance == null) {
00053             self::$_instance = new self();
00054         }
00055         return self::$_instance;
00056     }

osC_ErrorHandler::getIterator (  ) 

Definition at line 130 of file osC_ErrorHandler.php.

00131     {
00132         return $this->_observers; // SplObjectStorage est itératif :)
00133     }

osC_ErrorHandler::notify (  ) 

Definition at line 118 of file osC_ErrorHandler.php.

Referenced by error().

00119     {
00120         foreach ($this->_observers AS $observer) {
00121             try{
00122                 $observer->update($this); // délégation
00123             }catch(Exception $e){
00124                 die($e->getMessage());
00125             }
00126         }
00127     }

static osC_ErrorHandler::resetInstance (  )  [static]

Definition at line 58 of file osC_ErrorHandler.php.

00059     {
00060         self::$_instance = null;
00061         return self::getInstance();
00062     }

static osC_ErrorHandler::start (  )  [static]

Definition at line 71 of file osC_ErrorHandler.php.

00071                                  {
00072       set_error_handler(array(self::getInstance(),'error'));
00073       return self::getInstance();
00074   }

static osC_ErrorHandler::stop (  )  [static]

Definition at line 76 of file osC_ErrorHandler.php.

00076                                 {
00077       restore_error_handler();
00078       return self::getInstance();
00079   }


Member Data Documentation

osC_ErrorHandler::$_errfile [private]

Definition at line 41 of file osC_ErrorHandler.php.

osC_ErrorHandler::$_errline [private]

Definition at line 40 of file osC_ErrorHandler.php.

osC_ErrorHandler::$_errno [private]

Definition at line 38 of file osC_ErrorHandler.php.

osC_ErrorHandler::$_errstr [private]

Definition at line 39 of file osC_ErrorHandler.php.

osC_ErrorHandler::$_instance [static, protected]

Definition at line 43 of file osC_ErrorHandler.php.

osC_ErrorHandler::$_observers = array() [private]

Definition at line 42 of file osC_ErrorHandler.php.


The documentation for this class was generated from the following file: