Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
43
vendor/doctrine/rst-parser/lib/Meta/CachedMetasLoader.php
vendored
Normal file
43
vendor/doctrine/rst-parser/lib/Meta/CachedMetasLoader.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Meta;
|
||||
|
||||
use LogicException;
|
||||
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
final class CachedMetasLoader
|
||||
{
|
||||
public function loadCachedMetaEntries(string $targetDirectory, Metas $metas): void
|
||||
{
|
||||
$metaCachePath = $this->getMetaCachePath($targetDirectory);
|
||||
if (! file_exists($metaCachePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = file_get_contents($metaCachePath);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new LogicException(sprintf('Could not load file "%s"', $contents));
|
||||
}
|
||||
|
||||
$metas->setMetaEntries(unserialize($contents));
|
||||
}
|
||||
|
||||
public function cacheMetaEntries(string $targetDirectory, Metas $metas): void
|
||||
{
|
||||
file_put_contents($this->getMetaCachePath($targetDirectory), serialize($metas->getAll()));
|
||||
}
|
||||
|
||||
private function getMetaCachePath(string $targetDirectory): string
|
||||
{
|
||||
return $targetDirectory . '/metas.php';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue