dont allow using null as view root

This commit is contained in:
Robin Appelman 2015-04-22 14:51:02 +02:00
parent 42d9ba0f83
commit f391f88d7f
1 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,9 @@ class View {
* @throws \Exception If $root contains an invalid path
*/
public function __construct($root = '') {
if (is_null($root)) {
throw new \InvalidArgumentException('Root cant be null');
}
if(!Filesystem::isValidPath($root)) {
throw new \Exception();
}
@ -85,6 +88,9 @@ class View {
}
public function getAbsolutePath($path = '/') {
if ($path === null) {
return null;
}
$this->assertPathLength($path);
if ($path === '') {
$path = '/';