25 protected const SIZE =
'size';
26 protected const SHA1 =
'sha1';
29 private $fileStateByPath;
32 $this->fileStateByPath = [];
43 $this->fileStateByPath[
$path] = [
46 self::SHA1 => $sha1Base36
56 $this->fileStateByPath[
$path] = [
57 self::EXISTS =>
false,
71 return self::resolveFileProperty(
$path, self::EXISTS, $curExistenceFunc );
82 return self::resolveFileProperty(
$path, self::SIZE, $curSizeFunc );
93 return self::resolveFileProperty(
$path, self::SHA1, $curSha1Func );
102 private function resolveFileProperty(
$path, $property, $curValueFunc ) {
103 if ( isset( $this->fileStateByPath[
$path] ) ) {
105 $value = $this->fileStateByPath[
$path][$property];
106 if ( $value instanceof Closure ) {
108 $this->fileStateByPath[
$path][$property] = $value;
112 $value = $curValueFunc(
$path );
123 $snapshot =
new self();
124 foreach ( $paths as
$path ) {
125 if ( isset( $this->fileStateByPath[
$path] ) ) {
126 $snapshot->fileStateByPath[
$path] = $this->fileStateByPath[
$path];
135class_alias( FileStatePredicates::class,
'FileStatePredicates' );