| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contains the location to the configuration file(s) on disk. |
| 4 |
* |
| 5 |
* @package SolidWP\Performance |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Config; |
| 11 |
|
| 12 |
use InvalidArgumentException; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Contains the location to the configuration file(s) on disk. |
| 20 |
* |
| 21 |
* @package SolidWP\Performance |
| 22 |
*/ |
| 23 |
final class Config_File { |
| 24 |
|
| 25 |
/** |
| 26 |
* The server directory where the config file is stored. |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private string $dir; |
| 31 |
|
| 32 |
/** |
| 33 |
* @param string $dir The server directory where the config file is stored. |
| 34 |
* |
| 35 |
* @throws InvalidArgumentException If an empty directory is provided. |
| 36 |
*/ |
| 37 |
public function __construct( string $dir ) { |
| 38 |
if ( empty( $dir ) ) { |
| 39 |
throw new InvalidArgumentException( 'The config directory cannot be empty' ); |
| 40 |
} |
| 41 |
|
| 42 |
$this->dir = $dir; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* The server directory of the configuration file. |
| 47 |
* |
| 48 |
* @return string |
| 49 |
*/ |
| 50 |
public function dir(): string { |
| 51 |
return $this->dir; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* The full server path to the configuration file. |
| 56 |
* |
| 57 |
* @return string |
| 58 |
*/ |
| 59 |
public function get(): string { |
| 60 |
return $this->dir . '/config.php'; |
| 61 |
} |
| 62 |
} |
| 63 |
|