orbit/src/Orbit/Request.php

45 lines
1 KiB
PHP

<?php
namespace Orbit;
class Request
{
public $url = '';
public $scheme;
public $host;
public $port;
public $user;
public $pass;
public $path;
public $query;
public $fragment;
public function __construct($request_input)
{
$this->url = trim($request_input);
$data = parse_url($this->url);
foreach ($data as $key => $value) {
$this->{$key} = urldecode($value);
}
// If scheme is missing, infer as default scheme
if (!$this->scheme) {
$this->scheme = Server::SCHEME;
}
}
public function getUrlAppendPath($text)
{
return $this->scheme . '://'
. ($this->user ? $this->user : '')
. ($this->pass ? ':' . $this->pass : '')
. ($this->user ? '@' : '')
. $this->host
. ($this->port ? ':' . $this->port : '')
. $this->path . $text
. ($this->query ? '?' . $this->query : '')
. ($this->fragment ? '#' . $this->fragment : '');
}
}