Adam Pippin
3 years ago
3 changed files with 83 additions and 16 deletions
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
namespace App\Engine; |
|||
|
|||
class File |
|||
{ |
|||
/** @var string */ |
|||
protected $paths; |
|||
|
|||
public function __construct(array $paths) |
|||
{ |
|||
$this->paths = $paths; |
|||
} |
|||
|
|||
public function resolve(string $file) |
|||
{ |
|||
foreach ($this->paths as $path) |
|||
{ |
|||
if (file_exists($path.DIRECTORY_SEPARATOR.$file)) |
|||
{ |
|||
return realpath($path.DIRECTORY_SEPARATOR.$file); |
|||
} |
|||
} |
|||
throw new \Exception('File not found: '.$file); |
|||
} |
|||
|
|||
public function addPath(string $path) |
|||
{ |
|||
$this->paths[] = $path; |
|||
} |
|||
} |
Loading…
Reference in new issue