Fetch timestamp for a 410 error.
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns#2947616

@param int $statusCode
@param string $body
@return string
333052
private static function fetch410Timestamp(int $statusCode, string $body): string
    {
        if($statusCode === 410) {
            return (string)(json_decode($body, true)['timestamp'] ?: '');
        }
        return '';
    }
983812
public function output($statusCode)
    {
        // TODO: Refactor into a content-type option
        if (Director::is_ajax()) {
            return $this->getTitle();
        }

        $renderer = Debug::create_debug_view();
        $output = $renderer->renderHeader();
        $output .= $renderer->renderInfo("Website Error", $this->getTitle(), $this->getBody());

        $adminEmail = Email::config()->get('admin_email');
        if ($adminEmail) {
            $mailto = Email::obfuscate($adminEmail);
            $output .= $renderer->renderParagraph('Contact an administrator: ' . $mailto . '');
        }

        $output .= $renderer->renderFooter();
        return $output;
    }
289323
public function returnExceptionToThrow($status_code)
    {
        static $map = array (
            1  => 'E4xx_IndexOutOfBoundsWebDriverError',
            2  => 'E4xx_NoCollectionWebDriverError',
            3  => 'E4xx_NoStringWebDriverError',
            4  => 'E4xx_NoStringLengthWebDriverError',
            5  => 'E4xx_NoStringWrapperWebDriverError',
            6  => 'E4xx_NoSuchDriverWebDriverError',
            7  => 'E4xx_NoSuchElementWebDriverError',
            8  => 'E4xx_NoSuchFrameWebDriverError',
            9  => 'E5xx_UnknownCommandWebDriverError',
            10 => 'E4xx_ObsoleteElementWebDriverError',
            11 => 'E4xx_ElementNotDisplayedWebDriverError',
            12 => 'E5xx_InvalidElementStateWebDriverError',
            13 => 'E5xx_UnhandledWebDriverError',
            14 => 'E4xx_ExpectedWebDriverError',
            15 => 'E4xx_ElementNotSelectableWebDriverError',
            16 => 'E4xx_NoSuchDocumentWebDriverError',
            17 => 'E5xx_UnexpectedJavascriptWebDriverError',
            18 => 'E4xx_NoScriptResultWebDriverError',
            19 => 'E4xx_XPathLookupWebDriverError',
            20 => 'E4xx_NoSuchCollectionWebDriverError',
            21 => 'E4xx_TimeOutWebDriverError',
            22 => 'E5xx_NullPointerWebDriverError',
            23 => 'E4xx_NoSuchWindowWebDriverError',
            24 => 'E4xx_InvalidCookieDomainWebDriverError',
            25 => 'E4xx_UnableToSetCookieWebDriverError',
            26 => 'E4xx_UnexpectedAlertOpenWebDriverError',
            27 => 'E4xx_NoAlertOpenWebDriverError',
            28 => 'E4xx_ScriptTimeoutWebDriverError',
            29 => 'E4xx_InvalidElementCoordinatesWebDriverError',
            30 => 'E4xx_IMENotAvailableWebDriverError',
            31 => 'E5xx_IMEEngineActivationFailedWebDriverError',
            32 => 'E4xx_InvalidSelectorWebDriverError',
            33 => 'E5xx_SessionNotCreatedWebDriverError',
            34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError',
        );

        // did an error occur?
        if ($status_code == 0) {
            return null;
        }

        // is this a known problem?
        if (isset($map[$status_code])) {
            return __NAMESPACE__ . '\\' . $map[$status_code];
        }

        // we have an unknown exception
        return __NAMESPACE__ . '\\UnknownWebDriverError';
    }
692002
public function setStatusCode(int $statusCode, string $reasonPhrase = null): Response
    {
        $this->status->setCode($statusCode, $reasonPhrase);
        return $this;
    }
119280
public static function isClientError(int $statusCode): bool
    {
        return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR);
    }
859686
public function setStatusCode($statusCode)
    {
        $statusCode = (int)$statusCode;
        if ($statusCode < 100 || $statusCode >= 600) {
            throw new \Exception("Invalid status code: {$statusCode}.");
        }
        $this->statusCode = $statusCode;
        return $this;
    }
1349479
public static function statusClassFor(int $statusCode): string
    {
        $class = substr((string) $statusCode, 0, 1);
        return self::$statusClass[$class] ?? self::STATUS_CLASS_UNKNOWN;
    }
1299729
public function setStatusCode($statusCode, $text = null)
    {
        // Fallback status code message if missing
        if (! empty($text)) {
            $statusText = $text;
        } elseif (! empty(self::$statusTexts[$statusCode])) {
            $statusText = self::$statusTexts[$statusCode];
        } else {
            $statusText = 'Undefined code';
        }

        // Set status code and text
        $this->statusCode = $statusCode;
        $this->statusText = $statusText;

        // Validate status code
        if ($this->isInvalid()) {
            throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $statusCode));
        }

        return $this;
    }
1019411
public function json($data, $statusCode=null)
    {
        // Set Status Code
        if ($statusCode) {
            $this->setStatusCode($statusCode);
        }
        
        $this->setFormat(Response::FORMAT_JSON);

        if (!is_null($data)) {
            $this->setData($data);
        }
        
        return $this->send();
    }
921877
protected function getDefaultResponseContent(Exception $ex, int $statusCode) : string
    {
        if ($this->inDevelopmentEnvironment) {
            $content = $this->getDevelopmentEnvironmentContent($ex, $statusCode);
        } else {
            $content = $this->getProductionEnvironmentContent($ex, $statusCode);
        }

        return $content;
    }
702222
protected function getMetaResponse($meta, $statusCode = Response::HTTP_OK)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses       = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $encoder         = $this->codecMatcher->getEncoder();
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();
        $content         = $encoder->encodeMeta($meta);

        return $responses->getResponse($statusCode, $outputMediaType, $content, $this->supportedExtensions);
    }
15779
public function getAuthorizationCode($code)
    {
        $stmt = $this->db->prepare(sprintf('SELECT * from %s where authorization_code = :code', $this->config['code_table']));
        $stmt->execute(compact('code'));

        if ($code = $stmt->fetch()) {
            // convert date string back to timestamp
            $code['expires'] = strtotime($code['expires']);
        }

        return $code;
    }
1134662
function _extractStatusCodeFromBody( body ){
		let statusCode = 200;

		if( bodyHasStatusCode( body ) ){
			// Allow resolved responses to change status code
			statusCode = body.statusCode;
			delete body.statusCode;
		}
		return statusCode;
	}
1152249
public function send($code, $body = '')
    {
        if (!isset($this->codes[$code])) {
            $statusCode = 500;
            $body = 'API attempted to return an unknown HTTP status.';
        }
        // if the body wasn't defined, default to the inbuilt response
        if (!$body) $body = $this->codes[$code];
        header('HTTP/1.1 ' . $code . ' ' . $this->codes[$code]);
        header('Content-type: application/json');
        echo json_encode($body);
        exit;
    }
1023060
protected function _format($statusCode=null, $message=null, $body=false)
    {
        $format = [];
        // Status Code field is necessary
        $format['code'] = ($statusCode) 
            ?: $this->response->getStatusCode();
        // Message field
        if ($message) {
            $format['message'] = $message;
        }
        // Body field
        if ($body !== false) {
            $format['data'] = $body;
        }
        
        return $format;
    }
77486
private function retrieveErrorCode($body)
    {
        if (empty($body) || false === strpos($body, '<?xml')) {
            return '';
        }
        $xml = simplexml_load_string($body);
        if (isset($xml->Code)) {
            return strval($xml->Code);
        }
        return '';
    }
82044
public static function rpcCodeFromHttpStatusCode($httpStatusCode)
    {
        if (array_key_exists($httpStatusCode, self::$httpStatusCodeToRpcCodeMap)) {
            return self::$httpStatusCodeToRpcCodeMap[$httpStatusCode];
        }
        return ApiStatus::UNRECOGNIZED_CODE;
    }