Uri.php in Zircon Profile 8.0
File
vendor/zendframework/zend-feed/src/Uri.php
View source
<?php
namespace Zend\Feed;
class Uri {
protected $fragment;
protected $host;
protected $pass;
protected $path;
protected $port;
protected $query;
protected $scheme;
protected $user;
protected $valid;
protected $validSchemes = [
'http',
'https',
'file',
];
public function __construct($uri) {
$parsed = parse_url($uri);
if (false === $parsed) {
$this->valid = false;
return;
}
$this->scheme = isset($parsed['scheme']) ? $parsed['scheme'] : null;
$this->host = isset($parsed['host']) ? $parsed['host'] : null;
$this->port = isset($parsed['port']) ? $parsed['port'] : null;
$this->user = isset($parsed['user']) ? $parsed['user'] : null;
$this->pass = isset($parsed['pass']) ? $parsed['pass'] : null;
$this->path = isset($parsed['path']) ? $parsed['path'] : null;
$this->query = isset($parsed['query']) ? $parsed['query'] : null;
$this->fragment = isset($parsed['fragment']) ? $parsed['fragment'] : null;
}
public static function factory($uri) {
return new static($uri);
}
public function getHost() {
return $this->host;
}
public function getPath() {
return $this->path;
}
public function getScheme() {
return $this->scheme;
}
public function isValid() {
if (false === $this->valid) {
return false;
}
if ($this->scheme && !in_array($this->scheme, $this->validSchemes)) {
return false;
}
if ($this->host) {
if ($this->path && substr($this->path, 0, 1) != '/') {
return false;
}
return true;
}
if ($this->user || $this->port) {
return false;
}
if ($this->path) {
if (substr($this->path, 0, 2) == '//') {
return false;
}
return true;
}
if (!($this->query || $this->fragment)) {
return false;
}
return true;
}
public function isAbsolute() {
return $this->scheme !== null;
}
}