for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Linna PSR7
*
* @author Sebastian Rapetti <[email protected]>
* @copyright (c) 2017, Sebastian Rapetti
* @license http://opensource.org/licenses/MIT MIT License
*/
namespace Linna\Psr7;
* Uri trait.
* Provide help methods for Uri class.
trait UriTrait
{
* Create uri string.
* @param string $scheme
* @param string $authority
* @param string $path
* @param string $query
* @param string $fragment
* @return string
private function createUriString(
string $scheme,
string $authority,
string $path,
string $query,
string $fragment
) : string
$uri = $scheme.$authority;
$uri .= ('/' !== substr($path, 0, 1) && $uri !== '' && $path !== '') ? '/'.$path : $path;
$uri .= $query.$fragment;
return $uri;
}
* Get non standard port.
* @param int $port
* @param string $standardScheme
* @param array $supportedSchemes
* @return int
private function getNonStandardPort(
int $port,
string $standardScheme,
array $supportedSchemes
) : int
return (!$port && $standardScheme) ? $supportedSchemes[$scheme] : $port;
* Get port for standard scheme.
* @param int $standardPort
private function getPortForStandardScheme(int $standardPort, int $port) : int
return ($standardPort) ? 0 : $port;
* Check standard port for current scheme.
* @return bool
private function checkStandardPortForCurretScheme(string $scheme, int $port, array $supportedSchemes) : bool
return (isset($supportedSchemes[$scheme]) && $port === $supportedSchemes[$scheme]) ? true : false;