Added support for PHP7

This commit is contained in:
Simon Sessingø
2018-03-20 03:38:55 +01:00
parent d279d5598d
commit f23d569757
58 changed files with 678 additions and 532 deletions
+18 -13
View File
@@ -38,7 +38,7 @@ class Url
* Check if url is using a secure protocol like https
* @return bool
*/
public function isSecure()
public function isSecure(): bool
{
return (strtolower($this->getScheme()) === 'https');
}
@@ -47,7 +47,7 @@ class Url
* Checks if url is relative
* @return bool
*/
public function isRelative()
public function isRelative(): bool
{
return ($this->getHost() === null);
}
@@ -56,7 +56,7 @@ class Url
* Get url scheme
* @return string|null
*/
public function getScheme()
public function getScheme(): ?string
{
return $this->data['scheme'];
}
@@ -65,7 +65,7 @@ class Url
* Get url host
* @return string|null
*/
public function getHost()
public function getHost(): ?string
{
return $this->data['host'];
}
@@ -74,7 +74,7 @@ class Url
* Get url port
* @return int|null
*/
public function getPort()
public function getPort(): ?int
{
return ($this->data['port'] !== null) ? (int)$this->data['port'] : null;
}
@@ -83,7 +83,7 @@ class Url
* Parse username from url
* @return string|null
*/
public function getUserName()
public function getUserName(): ?string
{
return $this->data['user'];
}
@@ -92,7 +92,7 @@ class Url
* Parse password from url
* @return string|null
*/
public function getPassword()
public function getPassword(): ?string
{
return $this->data['pass'];
}
@@ -101,7 +101,7 @@ class Url
* Get path from url
* @return string
*/
public function getPath()
public function getPath(): ?string
{
return $this->data['path'];
}
@@ -110,7 +110,7 @@ class Url
* Get querystring from url
* @return string|null
*/
public function getQueryString()
public function getQueryString(): ?string
{
return $this->data['query'];
}
@@ -119,7 +119,7 @@ class Url
* Get fragment from url (everything after #)
* @return string|null
*/
public function getFragment()
public function getFragment(): ?string
{
return $this->data['fragment'];
}
@@ -127,7 +127,7 @@ class Url
/**
* @return string
*/
public function getOriginalUrl()
public function getOriginalUrl(): string
{
return $this->originalUrl;
}
@@ -139,7 +139,7 @@ class Url
* @throws MalformedUrlException
* @return array
*/
public function parseUrl($url, $component = -1)
public function parseUrl($url, $component = -1): array
{
$encodedUrl = preg_replace_callback(
'/[^:\/@?&=#]+/u',
@@ -158,11 +158,16 @@ class Url
return array_map('urldecode', $parts);
}
public function contains($value): bool
{
return (stripos($this->getOriginalUrl(), $value) === false);
}
/**
* Returns data array with information about the url
* @return array
*/
public function getData()
public function getData(): array
{
return $this->data;
}