1
0
mirror of https://github.com/flarum/core.git synced 2025-07-28 12:10:51 +02:00
Files
php-flarum/src/Foundation/Paths.php
Sami Mazouz bab084a75f Fix Paths test failing on Windows (#2187)
* Fix directory separator for windows os

* Change Paths to use a forward slash instead
2020-05-28 12:42:54 -04:00

45 lines
1.0 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Foundation;
use InvalidArgumentException;
/**
* @property-read string base
* @property-read string public
* @property-read string storage
* @property-read string vendor
*/
class Paths
{
private $paths;
public function __construct(array $paths)
{
if (! isset($paths['base'], $paths['public'], $paths['storage'])) {
throw new InvalidArgumentException(
'Paths array requires keys base, public and storage'
);
}
$this->paths = array_map(function ($path) {
return rtrim($path, '\/');
}, $paths);
// Assume a standard Composer directory structure unless specified
$this->paths['vendor'] = $this->vendor ?? $this->base.'/vendor';
}
public function __get($name): ?string
{
return $this->paths[$name] ?? null;
}
}