public function path()
{
$args = func_get_args();
switch (count($args)) {
case 1:
$file = $args[0];
if ($this->isAbsolutePath($file) && file_exists($file)) {
return $file;
}
$parts = explode(':', $file, 2);
if (count($parts) == 2) {
if (!isset($this->paths[$parts[0]])) {
return false;
}
foreach ($this->paths[$parts[0]] as &$path) {
if (file_exists($path . $parts[1])) {
return $path . $parts[1];
}
}
}
return false;
case 2:
if (!isset($this->paths[$args[0]])) {
$this->paths[$args[0]] = [];
}
array_unshift($this->paths[$args[0]], rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $args[1]), '/') . '/');
return $this;
}
return null;
}