mirror of
https://github.com/getformwork/formwork.git
synced 2025-03-14 19:19:48 +01:00
Add File::hash()
This commit is contained in:
parent
b5c522033a
commit
39faccb870
@ -59,6 +59,13 @@ class File
|
||||
*/
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* File hash
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hash;
|
||||
|
||||
/**
|
||||
* Create a new File instance
|
||||
*/
|
||||
@ -150,6 +157,17 @@ class File
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file hash
|
||||
*/
|
||||
public function hash(): string
|
||||
{
|
||||
if ($this->hash !== null) {
|
||||
return $this->hash;
|
||||
}
|
||||
return $this->hash = hash_file('sha256', $this->path);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user