public function addError($error, $passedMetaData = array())
 {
     // Check if this error should be sent to Bugsnag
     if (!$this->config->shouldNotify()) {
         return false;
     }
     // Add global meta-data to error
     $error->setMetaData($this->config->metaData);
     // Add request meta-data to error
     if (Bugsnag_Request::isRequest()) {
         $error->setMetaData(Bugsnag_Request::getRequestMetaData());
     }
     // Add environment meta-data to error
     if ($this->config->sendEnvironment && !empty($_ENV)) {
         $error->setMetaData(array("Environment" => $_ENV));
     }
     // Add user-specified meta-data to error
     $error->setMetaData($passedMetaData);
     // Run beforeNotify function (can cause more meta-data to be merged)
     if (isset($this->config->beforeNotifyFunction) && is_callable($this->config->beforeNotifyFunction)) {
         $beforeNotifyReturn = call_user_func($this->config->beforeNotifyFunction, $error);
     }
     // Skip this error if the beforeNotify function returned FALSE
     if (!isset($beforeNotifyReturn) || $beforeNotifyReturn !== false) {
         $this->errorQueue[] = $error;
         return true;
     } else {
         return false;
     }
 }
 /**
  * Get the current user.
  *
  * @return array
  */
 public function getUser()
 {
     $defaultUser = array();
     $userId = Bugsnag_Request::getUserId();
     if (!is_null($userId)) {
         $defaultUser['id'] = $userId;
     }
     return $this->config->get('user', $defaultUser);
 }
 private function sendErrorsOnShutdown()
 {
     return $this->config->batchSending && Bugsnag_Request::isRequest();
 }
 public function testRequestIp()
 {
     $this->assertEquals(Bugsnag_Request::getRequestIp(), "123.45.67.8");
 }