Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaszak committed Apr 21, 2016
1 parent 4f7054c commit 0dc5bbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Collection/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getRouteArray(): array
foreach ($this->fileArray as $file) {
$result = array_merge(
$result,
$this->parser->parse(file_get_contents($file))
$this->parser->parse(file_get_contents($file)) ?? []
);
}
return $this->converter->convert($result);
Expand Down
9 changes: 5 additions & 4 deletions src/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public function __construct(string $baseQuery = '')
*/
public function getBaseURL(): string
{
$serverName = $_SERVER['SERVER_NAME'] ?? '';
$url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') .
"://{$_SERVER['SERVER_NAME']}";
"://{$serverName}";
return !empty($this->baseQuery) ? $url . $this->baseQuery : $url;
}

Expand All @@ -52,12 +53,12 @@ public function getBaseURL(): string
*/
public function getQuery(): string
{
$requestURI = $_SERVER['REQUEST_URI'];
$requestURI = $_SERVER['REQUEST_URI'] ?? '';
if (empty($this->baseQuery)) {
return $requestURI;
} else {
return $requestURI != $this->baseQuery ?
substr(
(string)substr(
$requestURI,
strlen($this->baseQuery) - strlen($requestURI)
) : '';
Expand All @@ -70,6 +71,6 @@ public function getQuery(): string
*/
public function getHttpMethod(): string
{
return $_SERVER['REQUEST_METHOD'];
return $_SERVER['REQUEST_METHOD'] ?? '';
}
}

0 comments on commit 0dc5bbb

Please sign in to comment.