* Port utilities for Requests
* @package Requests\Utilities
namespace WpOrg\Requests;
use WpOrg\Requests\Exception;
use WpOrg\Requests\Exception\InvalidArgument;
* Find the correct port depending on the Request type.
* @package Requests\Utilities
* Port to use with Acap requests.
* Port to use with Dictionary requests.
* Port to use with HTTP requests.
* Port to use with HTTP over SSL requests.
* Retrieve the port number to use.
* @param string $type Request type.
* The following requests types are supported:
* 'acap', 'dict', 'http' and 'https'.
* @throws \WpOrg\Requests\Exception\InvalidArgument When a non-string input has been passed.
* @throws \WpOrg\Requests\Exception When a non-supported port is requested ('portnotsupported').
public static function get($type) {
throw InvalidArgument::create(1, '$type', 'string', gettype($type));
$type = strtoupper($type);
if (!defined("self::{$type}")) {
$message = sprintf('Invalid port type (%s) passed', $type);
throw new Exception($message, 'portnotsupported');
return constant("self::{$type}");