public function toArray()
    {
        $hasChainedException = PHP_VERSION_ID >= 50300;

        $exception = $this->exception;

        do {
            $whoops = $this->getWhoopsRunner();
            $whoops->pushHandler(new WhoopsHandler($this->config))->register();

            $exceptions[] = json_decode(
                $whoops->handleException($exception),
                true
            );
        } while ($hasChainedException && $exception = $exception->getPrevious());

        $data = [
            'title' => get_class($this->exception),
            'message' => $this->exception->getMessage(),
            'exception' => [
                'file' => $this->exception->getFile(),
                'line' => $this->exception->getLine(),
                'code' => $this->exception->getCode(),
            ],
            'platform' => 'php',
            'environment' => $this->config->getEnvironment(),
            'events' => [
                'exceptions' => $exceptions,
                'meta_data' => $this->config->getMetaData(),
                'user' => $this->config->getUser(),
                'sdk' => $this->config->getSdk(),
            ],
        ];

        if (empty($data['level'])) {
            if (method_exists($exception, 'getSeverity')) {
                $data['level'] = $this->translateSeverity($exception->getSeverity());
            } else {
                $data['level'] = self::ERROR;
            }
        }

        return $data;
    }