| 1 |
<?php |
| 2 |
/** |
| 3 |
* The meta file provides a single object to access the meta file |
| 4 |
* cache path for a URL. |
| 5 |
* |
| 6 |
* @package SolidWP\Performance |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types=1 ); |
| 10 |
|
| 11 |
namespace SolidWP\Performance\Page_Cache\Meta; |
| 12 |
|
| 13 |
use SolidWP\Performance\Page_Cache\Cache_Path; |
| 14 |
|
| 15 |
/** |
| 16 |
* The meta file provides a single object to access the meta file |
| 17 |
* cache path for a URL. |
| 18 |
* |
| 19 |
* @package SolidWP\Performance |
| 20 |
*/ |
| 21 |
final class Meta_File { |
| 22 |
|
| 23 |
public const EXT = '.meta.php'; |
| 24 |
|
| 25 |
/** |
| 26 |
* @var Cache_Path |
| 27 |
*/ |
| 28 |
private Cache_Path $cache_path; |
| 29 |
|
| 30 |
/** |
| 31 |
* @param Cache_Path $cache_path The cache path. |
| 32 |
*/ |
| 33 |
public function __construct( Cache_Path $cache_path ) { |
| 34 |
$this->cache_path = $cache_path; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Returns the full server path to a meta file associated with a URL. |
| 39 |
* |
| 40 |
* @param string $url The URL the meta is associated with. |
| 41 |
* |
| 42 |
* @throws \RuntimeException When URL does not have valid host. |
| 43 |
* |
| 44 |
* @return string e.g. /app/wp-content/cache/page/local.test.com/test-post.meta.php |
| 45 |
*/ |
| 46 |
public function get_path_from_url( string $url ): string { |
| 47 |
return $this->cache_path->get_path_from_url( $url ) . self::EXT; |
| 48 |
} |
| 49 |
} |
| 50 |
|