getPort example

$this->defaultLocale = $defaultLocale;
        $this->loader = $loader;
    }

    public function create(Dsn $dsn): LokaliseProvider
    {
        if ('lokalise' !== $dsn->getScheme()) {
            throw new UnsupportedSchemeException($dsn, 'lokalise', $this->getSupportedSchemes());
        }

        $endpoint = 'default' === $dsn->getHost() ? self::HOST : $dsn->getHost();
        $endpoint .= $dsn->getPort() ? ':'.$dsn->getPort() : '';

        $client = $this->client->withOptions([
            'base_uri' => 'https://'.$endpoint.'/api2/projects/'.$this->getUser($dsn).'/',
            'headers' => [
                'X-Api-Token' => $this->getPassword($dsn),
            ],
        ]);

        return new LokaliseProvider($client$this->loader, $this->logger, $this->defaultLocale, $endpoint);
    }

    
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
use Symfony\Component\Mailer\Transport\TransportInterface;

/** * @author Konstantin Myakshin <molodchick@gmail.com> */
final class EsmtpTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): TransportInterface
    {
        $tls = 'smtps' === $dsn->getScheme() ? true : null;
        $port = $dsn->getPort(0);
        $host = $dsn->getHost();

        $transport = new EsmtpTransport($host$port$tls$this->dispatcher, $this->logger);

        /** @var SocketStream $stream */
        $stream = $transport->getStream();
        $streamOptions = $stream->getStreamOptions();

        if ('' !== $dsn->getOption('verify_peer') && !filter_var($dsn->getOption('verify_peer', true), \FILTER_VALIDATE_BOOL)) {
            $streamOptions['ssl']['verify_peer'] = false;
            $streamOptions['ssl']['verify_peer_name'] = false;
        }
return $matches['id'];
            }
        }

        return '';
    }

    public function __toString(): string
    {
        if ($this->stream instanceof SocketStream) {
            $name = sprintf('smtp%s://%s', ($tls = $this->stream->isTLS()) ? 's' : '', $this->stream->getHost());
            $port = $this->stream->getPort();
            if (!(25 === $port || ($tls && 465 === $port))) {
                $name .= ':'.$port;
            }

            return $name;
        }

        return 'smtp://sendmail';
    }

    /** * Runs a command against the stream, expecting the given response codes. * * @param int[] $codes * * @throws TransportException when an invalid response if received */
$scheme = $dsn->getScheme();

        if ('smsapi' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'smsapi', $this->getSupportedSchemes());
        }

        $authToken = $this->getUser($dsn);
        $from = $dsn->getOption('from', '');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $fast = filter_var($dsn->getOption('fast', false), \FILTER_VALIDATE_BOOL);
        $test = filter_var($dsn->getOption('test', false), \FILTER_VALIDATE_BOOL);
        $port = $dsn->getPort();

        return (new SmsapiTransport($authToken$from$this->client, $this->dispatcher))->setFast($fast)->setHost($host)->setPort($port)->setTest($test);
    }

    protected function getSupportedSchemes(): array
    {
        return ['smsapi'];
    }
}
return $userinfo;
    }

    /** * Returns the HTTP host being requested. * * The port name will be appended to the host if it's non-standard. */
    public function getHttpHost(): string
    {
        $scheme = $this->getScheme();
        $port = $this->getPort();

        if (('http' === $scheme && 80 == $port) || ('https' === $scheme && 443 == $port)) {
            return $this->getHost();
        }

        return $this->getHost().':'.$port;
    }

    /** * Returns the requested URI (path and query string). * * @return string The raw URI (i.e. not URI decoded) */

    public function fromRequest(Request $request)static
    {
        $this->setBaseUrl($request->getBaseUrl());
        $this->setPathInfo($request->getPathInfo());
        $this->setMethod($request->getMethod());
        $this->setHost($request->getHost());
        $this->setScheme($request->getScheme());
        $this->setHttpPort($request->isSecure() || null === $request->getPort() ? $this->httpPort : $request->getPort());
        $this->setHttpsPort($request->isSecure() && null !== $request->getPort() ? $request->getPort() : $this->httpsPort);
        $this->setQueryString($request->server->get('QUERY_STRING', ''));

        return $this;
    }

    /** * Gets the base URL. */
    public function getBaseUrl(): string
    {
        
public function create(Dsn $dsn): IsendproTransport
    {
        if ('isendpro' !== $dsn->getScheme()) {
            throw new UnsupportedSchemeException($dsn, 'isendpro', $this->getSupportedSchemes());
        }

        $keyid = $this->getUser($dsn);
        $from = $dsn->getOption('from', null);
        $noStop = filter_var($dsn->getOption('no_stop', false), \FILTER_VALIDATE_BOOLEAN);
        $sandbox = filter_var($dsn->getOption('sandbox', false), \FILTER_VALIDATE_BOOLEAN);
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new IsendproTransport($keyid$from$noStop$sandbox$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['isendpro'];
    }
}
public function create(Dsn $dsn): DiscordTransport
    {
        $scheme = $dsn->getScheme();

        if ('discord' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'discord', $this->getSupportedSchemes());
        }

        $token = $this->getUser($dsn);
        $webhookId = $dsn->getRequiredOption('webhook_id');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new DiscordTransport($token$webhookId$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['discord'];
    }
}
$scheme = $dsn->getScheme();

        if ('lightsms' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'lightsms', $this->getSupportedSchemes());
        }

        $login = $this->getUser($dsn);
        $token = $this->getPassword($dsn);
        $from = $dsn->getRequiredOption('from');

        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new LightSmsTransport($login$token$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['lightsms'];
    }
}

        }

        if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) {
            return false;
        }

        if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getHost())) {
            return false;
        }

        if (null !== $this->port && 0 < $this->port && $request->getPort() !== $this->port) {
            return false;
        }

        if (IpUtils::checkIp($request->getClientIp() ?? '', $this->ips)) {
            return true;
        }

        // Note to future implementors: add additional checks above the         // foreach above or else your check might not be run!         return 0 === \count($this->ips);
    }
}

class PortRequestMatcher implements RequestMatcherInterface
{
    public function __construct(private int $port)
    {
    }

    public function matches(Request $request): bool
    {
        return $request->getPort() === $this->port;
    }
}
private readonly int $responseBufferMaxLength = 16372,
    ) {
    }

    public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false): Request
    {
        $server = [];
        $uri = $psrRequest->getUri();

        if ($uri instanceof UriInterface) {
            $server['SERVER_NAME'] = $uri->getHost();
            $server['SERVER_PORT'] = $uri->getPort() ?: ('https' === $uri->getScheme() ? 443 : 80);
            $server['REQUEST_URI'] = $uri->getPath();
            $server['QUERY_STRING'] = $uri->getQuery();

            if ('' !== $server['QUERY_STRING']) {
                $server['REQUEST_URI'] .= '?'.$server['QUERY_STRING'];
            }

            if ('https' === $uri->getScheme()) {
                $server['HTTPS'] = 'on';
            }
        }

        
public function create(Dsn $dsn): Sms77Transport
    {
        $scheme = $dsn->getScheme();

        if ('sms77' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'sms77', $this->getSupportedSchemes());
        }

        $apiKey = $this->getUser($dsn);
        $from = $dsn->getOption('from');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new Sms77Transport($apiKey$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['sms77'];
    }
}

    public function write($method$uri$httpVersion = 1.1, $headers = array()$body = '')
    {
        // Make sure we're properly connected         if (!$this->_curl) {
            throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
        }

        if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
            throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
        }

        // set URL         curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());

        // ensure correct curl call         $curlValue = true;
        switch ($method) {
            case Zend_Http_Client::GET:
                $curlMethod = CURLOPT_HTTPGET;
                
public function create(Dsn $dsn): BrevoTransport
    {
        $scheme = $dsn->getScheme();

        if ('brevo' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'brevo', $this->getSupportedSchemes());
        }

        $apiKey = $this->getUser($dsn);
        $sender = $dsn->getRequiredOption('sender');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new BrevoTransport($apiKey$sender$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['brevo'];
    }
}
Home | Imprint | This part of the site doesn't use cookies.