WpOrg\Requests\Exception

Http::get_class()public staticWP 1.0

Get the correct exception class for a given error code

Method of the class: Http{}

No Hooks.

Return

String. Exception class name to use

Usage

$result = Http::get_class( $code );
$code(int|true|false) (required)
HTTP status code, or false if unavailable

Http::get_class() code WP 6.6.2

public static function get_class($code) {
	if (!$code) {
		return StatusUnknown::class;
	}

	$class = sprintf('\WpOrg\Requests\Exception\Http\Status%d', $code);
	if (class_exists($class)) {
		return $class;
	}

	return StatusUnknown::class;
}