Extend simple file with extension getter

Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
Christopher Ng 2022-03-03 05:10:57 +00:00
parent f1604cf7af
commit 0571391b10
4 changed files with 30 additions and 0 deletions

View File

@ -190,6 +190,17 @@ class NewSimpleFile implements ISimpleFile {
}
}
/**
* {@inheritDoc}
*/
public function getExtension(): string {
if ($this->file) {
return $this->file->getExtension();
} else {
return \pathinfo($this->name, PATHINFO_EXTENSION);
}
}
/**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*

View File

@ -158,6 +158,13 @@ class SimpleFile implements ISimpleFile {
return $this->file->getMimeType();
}
/**
* {@inheritDoc}
*/
public function getExtension(): string {
return $this->file->getExtension();
}
/**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*

View File

@ -102,6 +102,11 @@ interface ISimpleFile {
*/
public function getMimeType();
/**
* @since 24.0.0
*/
public function getExtension(): string;
/**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*

View File

@ -126,6 +126,13 @@ class InMemoryFile implements ISimpleFile {
return $fileInfo->buffer($this->contents);
}
/**
* {@inheritDoc}
*/
public function getExtension(): string {
return \pathinfo($this->name, PATHINFO_EXTENSION);
}
/**
* Stream reading is unsupported for in memory files.
*