diff options
author | marvin-borner@live.com | 2018-04-10 21:50:16 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-10 21:54:48 +0200 |
commit | fc9401f04a3aca5abb22f87ebc210de8afe11d32 (patch) | |
tree | b0b310f3581764ec3955f4e496a05137a32951c3 /assets/php/vendor/react/socket/src/FixedUriConnector.php | |
parent | 286d643180672f20526f3dc3bd19d7b751e2fa97 (diff) |
Initial Commit
Diffstat (limited to 'assets/php/vendor/react/socket/src/FixedUriConnector.php')
-rw-r--r-- | assets/php/vendor/react/socket/src/FixedUriConnector.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/assets/php/vendor/react/socket/src/FixedUriConnector.php b/assets/php/vendor/react/socket/src/FixedUriConnector.php new file mode 100644 index 0000000..057bcdf --- /dev/null +++ b/assets/php/vendor/react/socket/src/FixedUriConnector.php @@ -0,0 +1,41 @@ +<?php + +namespace React\Socket; + +/** + * Decorates an existing Connector to always use a fixed, preconfigured URI + * + * This can be useful for consumers that do not support certain URIs, such as + * when you want to explicitly connect to a Unix domain socket (UDS) path + * instead of connecting to a default address assumed by an higher-level API: + * + * ```php + * $connector = new FixedUriConnector( + * 'unix:///var/run/docker.sock', + * new UnixConnector($loop) + * ); + * + * // destination will be ignored, actually connects to Unix domain socket + * $promise = $connector->connect('localhost:80'); + * ``` + */ +class FixedUriConnector implements ConnectorInterface +{ + private $uri; + private $connector; + + /** + * @param string $uri + * @param ConnectorInterface $connector + */ + public function __construct($uri, ConnectorInterface $connector) + { + $this->uri = $uri; + $this->connector = $connector; + } + + public function connect($_) + { + return $this->connector->connect($this->uri); + } +} |