src/ch/timesplinter/core/Core.php
protected function createHttpRequest()
	{
		$protocol = (isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] === 'on') ? HttpRequest::PROTOCOL_HTTPS : HttpRequest::PROTOCOL_HTTP;
		$uri = StringUtils::startsWith($_SERVER['REQUEST_URI'], '/index.php')?StringUtils::afterFirst($_SERVER['REQUEST_URI'], '/index.php'):$_SERVER['REQUEST_URI'];

		$subFolder = StringUtils::afterFirst(getcwd(), $_SERVER['DOCUMENT_ROOT']);
		$cleanPath = StringUtils::between($uri, $subFolder, '?');

		$languages = array();
		$langsRates = explode(',', isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null);

		foreach($langsRates as $lr) {
			$lrParts = explode(';', $lr);

			$languages[$lrParts[0]] = isset($lrParts[1])?(float)StringUtils::afterFirst($lrParts[1], 'q='):1.0;
		}

		$requestTime = new \DateTime();
		$requestTime->setTimestamp($_SERVER['REQUEST_TIME']);

		$httpRequest = new HttpRequest();

		$httpRequest->setHost($_SERVER['SERVER_NAME']);
		$httpRequest->setPath($cleanPath);
		$httpRequest->setPort($_SERVER['SERVER_PORT']);
		$httpRequest->setProtocol($protocol);
		$httpRequest->setQuery($_SERVER['QUERY_STRING']);
		$httpRequest->setURI($uri);

		$httpRequest->setRequestTime($requestTime);
		$httpRequest->setRequestMethod($_SERVER['REQUEST_METHOD']);
		$httpRequest->setUserAgent(isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null);
		$httpRequest->setLanguages($languages);
		$httpRequest->setAcceptLanguage(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:null);
		$httpRequest->setRemoteAddress($_SERVER['REMOTE_ADDR']);
		$httpRequest->setReferrer(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);

		return $httpRequest;
	}
protected function createHttpRequest()
	{
		$protocol = (isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] === 'on') ? HttpRequest::PROTOCOL_HTTPS : HttpRequest::PROTOCOL_HTTP;
		$uri = StringUtils::startsWith($_SERVER['REQUEST_URI'], '/index.php')?StringUtils::afterFirst($_SERVER['REQUEST_URI'], '/index.php'):$_SERVER['REQUEST_URI'];

		$subFolder = StringUtils::afterFirst(getcwd(), $_SERVER['DOCUMENT_ROOT']);
		$cleanPath = StringUtils::between($uri, $subFolder, '?');

		$languages = array();
		$langsRates = explode(',', isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null);

		foreach($langsRates as $lr) {
			$lrParts = explode(';', $lr);

			$languages[$lrParts[0]] = isset($lrParts[1])?(float)StringUtils::afterFirst($lrParts[1], 'q='):1.0;
		}

		$requestTime = new \DateTime();
		$requestTime->setTimestamp($_SERVER['REQUEST_TIME']);

		$httpRequest = new HttpRequest();

		$httpRequest->setHost($_SERVER['SERVER_NAME']);
		$httpRequest->setPath($cleanPath);
		$httpRequest->setPort($_SERVER['SERVER_PORT']);
		$httpRequest->setProtocol($protocol);
		$httpRequest->setQuery($_SERVER['QUERY_STRING']);
		$httpRequest->setURI($uri);

		$httpRequest->setRequestTime($requestTime);
		$httpRequest->setRequestMethod($_SERVER['REQUEST_METHOD']);
		$httpRequest->setUserAgent(isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null);
		$httpRequest->setLanguages($languages);
		$httpRequest->setAcceptLanguage(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:null);
		$httpRequest->setRemoteAddress($_SERVER['REMOTE_ADDR']);
		$httpRequest->setReferrer(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);

		return $httpRequest;
	}
protected function createHttpRequest ( ) { $ protocol = ( isset ( $ _SERVER [ 'HTTPS' ] ) === true && $ _SERVER [ 'HTTPS' ] === 'on' ) ? HttpRequest :: PROTOCOL_HTTPS : HttpRequest :: PROTOCOL_HTTP ; $ uri = StringUtils :: startsWith ( $ _SERVER [ 'REQUEST_URI' ] , '/index.php' ) ? StringUtils :: afterFirst ( $ _SERVER [ 'REQUEST_URI' ] , '/index.php' ) : $ _SERVER [ 'REQUEST_URI' ] ; $ subFolder = StringUtils :: afterFirst ( getcwd ( ) , $ _SERVER [ 'DOCUMENT_ROOT' ] ) ; $ cleanPath = StringUtils :: between ( $ uri , $ subFolder , '?' ) ; $ languages = array ( ) ; $ langsRates = explode ( ',' , isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : null ) ; foreach ( $ langsRates as $ lr ) { $ lrParts = explode ( ';' , $ lr ) ; $ languages [ $ lrParts [ 0 ] ] = isset ( $ lrParts [ 1 ] ) ? ( float ) StringUtils :: afterFirst ( $ lrParts [ 1 ] , 'q=' ) : 1.0 ; } $ requestTime = new \ DateTime ( ) ; $ requestTime -> setTimestamp ( $ _SERVER [ 'REQUEST_TIME' ] ) ; $ httpRequest = new HttpRequest ( ) ; $ httpRequest -> setHost ( $ _SERVER [ 'SERVER_NAME' ] ) ; $ httpRequest -> setPath ( $ cleanPath ) ; $ httpRequest -> setPort ( $ _SERVER [ 'SERVER_PORT' ] ) ; $ httpRequest -> setProtocol ( $ protocol ) ; $ httpRequest -> setQuery ( $ _SERVER [ 'QUERY_STRING' ] ) ; $ httpRequest -> setURI ( $ uri ) ; $ httpRequest -> setRequestTime ( $ requestTime ) ; $ httpRequest -> setRequestMethod ( $ _SERVER [ 'REQUEST_METHOD' ] ) ; $ httpRequest -> setUserAgent ( isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : null ) ; $ httpRequest -> setLanguages ( $ languages ) ; $ httpRequest -> setAcceptLanguage ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : null ) ; $ httpRequest -> setRemoteAddress ( $ _SERVER [ 'REMOTE_ADDR' ] ) ; $ httpRequest -> setReferrer ( isset ( $ _SERVER [ 'HTTP_REFERER' ] ) ? $ _SERVER [ 'HTTP_REFERER' ] : null ) ; return $ httpRequest ; }
Creates a HttpRequest object for the current request
@return HttpRequest
Creates a HttpRequest object for the current request