path = ltrim( str_replace( '\\', '/', (string) $a['path'] ), '/' ); $f->size = isset( $a['size'] ) ? (int) $a['size'] : 0; $f->readable = isset( $a['readable'] ) ? (bool) $a['readable'] : true; $f->md5 = isset( $a['md5'] ) ? strtolower( (string) $a['md5'] ) : null; $f->sha256 = isset( $a['sha256'] ) ? strtolower( (string) $a['sha256'] ) : null; $f->head = isset( $a['head'] ) ? (string) $a['head'] : null; $f->content = isset( $a['content'] ) ? (string) $a['content'] : null; $f->mtime = isset( $a['mtime'] ) ? (int) $a['mtime'] : null; if ( null === $f->head && null !== $f->content ) { $f->head = substr( $f->content, 0, Assumptions::HEAD_BYTES ); } return $f; } public function toArray(): array { return array( 'path' => $this->path, 'size' => $this->size, 'readable' => $this->readable, 'md5' => $this->md5, 'sha256' => $this->sha256, 'head' => $this->head, 'content' => $this->content, 'mtime' => $this->mtime, ); } /** Content if read, else head, else ''. Always bounded by CONTENT_MAX_BYTES. */ public function text(): string { $t = null !== $this->content ? $this->content : (string) $this->head; return substr( $t, 0, Assumptions::CONTENT_MAX_BYTES ); } }