private function filterPort($port) { if ($port === null) { return null; } $port = (int) $port; if (1 > $port || 0xffff < $port) { throw new \InvalidArgumentException(sprintf('Invalid port: %d. Must be between 1 and 65535', $port)); } return $port; }