<?php /** * Port utilities for Requests * * @package Requests\Utilities * @since 2.0.0 */ namespace WpOrg\Requests; use WpOrg\Requests\Exception; use WpOrg\Requests\Exception\InvalidArgument; /** * Find the correct port depending on the Request type. * * @package Requests\Utilities * @since 2.0.0 */ final class Port { /** * Port to use with Acap requests. * * @var int */ const ACAP = 674; /** * Port to use with Dictionary requests. * * @var int */ const DICT = 2628; /** * Port to use with HTTP requests. * * @var int */ const HTTP = 80; /** * Port to use with HTTP over SSL requests. * * @var int */ const HTTPS = 443; /** * Retrieve the port number to use. * * @param string $type Request type. * The following requests types are supported: * 'acap', 'dict', 'http' and 'https'. * * @return int * * @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) { if (!is_string($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}"); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Auth | Folder | 0755 |
|
|
Cookie | Folder | 0755 |
|
|
Exception | Folder | 0755 |
|
|
Proxy | Folder | 0755 |
|
|
Response | Folder | 0755 |
|
|
Transport | Folder | 0755 |
|
|
Utility | Folder | 0755 |
|
|
Auth.php | File | 860 B | 0644 |
|
Autoload.php | File | 9.12 KB | 0644 |
|
Capability.php | File | 652 B | 0644 |
|
Cookie.php | File | 15.03 KB | 0644 |
|
Exception.php | File | 1.09 KB | 0644 |
|
HookManager.php | File | 709 B | 0644 |
|
Hooks.php | File | 2.96 KB | 0644 |
|
IdnaEncoder.php | File | 12.14 KB | 0644 |
|
Ipv6.php | File | 5.51 KB | 0644 |
|
Iri.php | File | 28.93 KB | 0644 |
|
Port.php | File | 1.47 KB | 0644 |
|
Proxy.php | File | 867 B | 0644 |
|
Requests.php | File | 33.2 KB | 0644 |
|
Response.php | File | 4.18 KB | 0644 |
|
Session.php | File | 8.89 KB | 0644 |
|
Ssl.php | File | 5.3 KB | 0644 |
|
Transport.php | File | 1.51 KB | 0644 |
|