summaryrefslogtreecommitdiff
path: root/vendor/OAuth/Common/Http/Uri/UriFactory.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-04 21:33:05 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-04 21:33:05 -0500
commit135b921db75da5995eab7e36393ecd4d2b0bc66f (patch)
tree46efc60fcf1f9d5c57ab1fb9418c2acfbda0698a /vendor/OAuth/Common/Http/Uri/UriFactory.php
parent850645dd6b22f5b495d1680e0b49540e0ebf9bd3 (diff)
Switch to composer
Diffstat (limited to 'vendor/OAuth/Common/Http/Uri/UriFactory.php')
-rwxr-xr-xvendor/OAuth/Common/Http/Uri/UriFactory.php168
1 files changed, 0 insertions, 168 deletions
diff --git a/vendor/OAuth/Common/Http/Uri/UriFactory.php b/vendor/OAuth/Common/Http/Uri/UriFactory.php
deleted file mode 100755
index 127aa203..00000000
--- a/vendor/OAuth/Common/Http/Uri/UriFactory.php
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-
-namespace OAuth\Common\Http\Uri;
-
-use RuntimeException;
-
-/**
- * Factory class for uniform resource indicators
- */
-class UriFactory implements UriFactoryInterface
-{
- /**
- * Factory method to build a URI from a super-global $_SERVER array.
- *
- * @param array $_server
- *
- * @return UriInterface
- */
- public function createFromSuperGlobalArray(array $_server)
- {
- if ($uri = $this->attemptProxyStyleParse($_server)) {
- return $uri;
- }
-
- $scheme = $this->detectScheme($_server);
- $host = $this->detectHost($_server);
- $port = $this->detectPort($_server);
- $path = $this->detectPath($_server);
- $query = $this->detectQuery($_server);
-
- return $this->createFromParts($scheme, '', $host, $port, $path, $query);
- }
-
- /**
- * @param string $absoluteUri
- *
- * @return UriInterface
- */
- public function createFromAbsolute($absoluteUri)
- {
- return new Uri($absoluteUri);
- }
-
- /**
- * Factory method to build a URI from parts
- *
- * @param string $scheme
- * @param string $userInfo
- * @param string $host
- * @param string $port
- * @param string $path
- * @param string $query
- * @param string $fragment
- *
- * @return UriInterface
- */
- public function createFromParts($scheme, $userInfo, $host, $port, $path = '', $query = '', $fragment = '')
- {
- $uri = new Uri();
- $uri->setScheme($scheme);
- $uri->setUserInfo($userInfo);
- $uri->setHost($host);
- $uri->setPort($port);
- $uri->setPath($path);
- $uri->setQuery($query);
- $uri->setFragment($fragment);
-
- return $uri;
- }
-
- /**
- * @param array $_server
- *
- * @return UriInterface|null
- */
- private function attemptProxyStyleParse($_server)
- {
- // If the raw HTTP request message arrives with a proxy-style absolute URI in the
- // initial request line, the absolute URI is stored in $_SERVER['REQUEST_URI'] and
- // we only need to parse that.
- if (isset($_server['REQUEST_URI']) && parse_url($_server['REQUEST_URI'], PHP_URL_SCHEME)) {
- return new Uri($_server['REQUEST_URI']);
- }
-
- return null;
- }
-
- /**
- * @param array $_server
- *
- * @return string
- *
- * @throws RuntimeException
- */
- private function detectPath($_server)
- {
- if (isset($_server['REQUEST_URI'])) {
- $uri = $_server['REQUEST_URI'];
- } elseif (isset($_server['REDIRECT_URL'])) {
- $uri = $_server['REDIRECT_URL'];
- } else {
- throw new RuntimeException('Could not detect URI path from superglobal');
- }
-
- $queryStr = strpos($uri, '?');
- if ($queryStr !== false) {
- $uri = substr($uri, 0, $queryStr);
- }
-
- return $uri;
- }
-
- /**
- * @param array $_server
- *
- * @return string
- */
- private function detectHost(array $_server)
- {
- $host = isset($_server['HTTP_HOST']) ? $_server['HTTP_HOST'] : '';
-
- if (strstr($host, ':')) {
- $host = parse_url($host, PHP_URL_HOST);
- }
-
- return $host;
- }
-
- /**
- * @param array $_server
- *
- * @return string
- */
- private function detectPort(array $_server)
- {
- return isset($_server['SERVER_PORT']) ? $_server['SERVER_PORT'] : 80;
- }
-
- /**
- * @param array $_server
- *
- * @return string
- */
- private function detectQuery(array $_server)
- {
- return isset($_server['QUERY_STRING']) ? $_server['QUERY_STRING'] : '';
- }
-
- /**
- * Determine URI scheme component from superglobal array
- *
- * When using ISAPI with IIS, the value will be "off" if the request was
- * not made through the HTTPS protocol. As a result, we filter the
- * value to a bool.
- *
- * @param array $_server A super-global $_SERVER array
- *
- * @return string Returns http or https depending on the URI scheme
- */
- private function detectScheme(array $_server)
- {
- if (isset($_server['HTTPS']) && filter_var($_server['HTTPS'], FILTER_VALIDATE_BOOLEAN)) {
- return 'https';
- } else {
- return 'http';
- }
- }
-}