WpOrgRequestsPort

Port number utilities for the Requests library.

Source: wp-includes/Requests/src/Port.php
Namespace: WpOrgRequests
Package: RequestsUtilities
Since: 2.0.0
Modifier: final


Overview

Provides well-known port constants and a method to retrieve the port number for a given request type.


Constants

ConstantValueDescription
ACAP674Port for ACAP requests
DICT2628Port for Dictionary requests
HTTP80Port for HTTP requests
HTTPS443Port for HTTPS requests

Methods

get()

Retrieve the port number for a given request type.

php
public static function get( string $type ): int
ParameterTypeDescription
$typestringRequest type: 'acap', 'dict', 'http', or 'https' (case-insensitive)

Returns: int — The port number.

The type is uppercased internally and looked up as a class constant via defined("self::{$type}") / constant("self::{$type}").

Throws:

  • InvalidArgument when $type is not a string.
  • Exception with type portnotsupported when the requested port type has no corresponding constant.