eee
This commit is contained in:
+45
-1
@@ -8,6 +8,13 @@ class ScanManifest
|
||||
{
|
||||
private array $entries = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param int $mtime
|
||||
* @param array $classes
|
||||
* @return void
|
||||
*/
|
||||
public function set(string $path, int $mtime, array $classes): void
|
||||
{
|
||||
$this->entries[$path] = [
|
||||
@@ -16,21 +23,41 @@ class ScanManifest
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $path): bool
|
||||
{
|
||||
return isset($this->entries[$path]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMtime(string $path): ?int
|
||||
{
|
||||
return $this->entries[$path]['mtime'] ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
public function getClasses(string $path): array
|
||||
{
|
||||
return $this->entries[$path]['classes'] ?? [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
public function remove(string $path): array
|
||||
{
|
||||
$classes = $this->getClasses($path);
|
||||
@@ -38,20 +65,37 @@ class ScanManifest
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string|null $prefix
|
||||
* @return array
|
||||
*/
|
||||
public function paths(?string $prefix = null): array
|
||||
{
|
||||
if ($prefix === null) {
|
||||
return array_keys($this->entries);
|
||||
}
|
||||
|
||||
return array_values(array_filter(array_keys($this->entries), fn(string $path) => str_starts_with($path, $prefix)));
|
||||
return $this->entries
|
||||
|> array_keys(...)
|
||||
|> (fn($x) => array_filter($x, fn(string $path) => str_starts_with($path, $prefix)))
|
||||
|> array_values(...);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $entries
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray(array $entries): void
|
||||
{
|
||||
$this->entries = [];
|
||||
|
||||
Reference in New Issue
Block a user