Beispiel #1
0
 /**
  * Simply delegates to send() if config option "sendOnShutdown" is disabled
  * or enqueues the request by registering a PHP shutdown function.
  */
 public function fire()
 {
     if ($this->config->getSendOnShutdown()) {
         // This dumb variable assignment is needed as PHP prohibits using
         // $this in closure use statements
         $instance = $this;
         // We use a closure here to retain the current values/states of
         // this instance and $request (as the use statement will copy them
         // into its own scope)
         register_shutdown_function(function () use($instance) {
             $instance->_send();
         });
     } else {
         $this->_send();
     }
 }
Beispiel #2
0
 /**
  * For internal use only. Will trigger an error according to the current
  * Config::$errorSeverity setting.
  * 
  * @see Config::$errorSeverity
  * @param string $message
  * @param string $method
  */
 public static function _raiseError($message, $method)
 {
     $method = str_replace(__NAMESPACE__ . '\\', '', $method);
     $message = $method . '(): ' . $message;
     $errorSeverity = isset(static::$config) ? static::$config->getErrorSeverity() : Config::ERROR_SEVERITY_EXCEPTIONS;
     switch ($errorSeverity) {
         case Config::ERROR_SEVERITY_SILENCE:
             // Do nothing
             break;
         case Config::ERROR_SEVERITY_WARNINGS:
             trigger_error($message, E_USER_WARNING);
             break;
         case Config::ERROR_SEVERITY_EXCEPTIONS:
             throw new Exception($message);
             break;
     }
 }