39 protected const SIZE =
'size';
40 protected const SHA1 =
'sha1';
43 private $fileStateByPath;
46 $this->fileStateByPath = [];
57 $this->fileStateByPath[
$path] = [
60 self::SHA1 => $sha1Base36
70 $this->fileStateByPath[
$path] = [
71 self::EXISTS =>
false,
85 return self::resolveFileProperty(
$path, self::EXISTS, $curExistenceFunc );
96 return self::resolveFileProperty(
$path, self::SIZE, $curSizeFunc );
107 return self::resolveFileProperty(
$path, self::SHA1, $curSha1Func );
116 private function resolveFileProperty(
$path, $property, $curValueFunc ) {
117 if ( isset( $this->fileStateByPath[
$path] ) ) {
119 $value = $this->fileStateByPath[
$path][$property];
120 if ( $value instanceof Closure ) {
122 $this->fileStateByPath[
$path][$property] = $value;
126 $value = $curValueFunc(
$path );
137 $snapshot =
new self();
138 foreach ( $paths as
$path ) {
139 if ( isset( $this->fileStateByPath[
$path] ) ) {
140 $snapshot->fileStateByPath[
$path] = $this->fileStateByPath[
$path];
149class_alias( FileStatePredicates::class,
'FileStatePredicates' );