Compare commits
No commits in common. "306efa37696f80b5a8e5eeee3c9d86a37547c772" and "2f68acdfc1c098229232c1348877dd13a99e7723" have entirely different histories.
306efa3769
...
2f68acdfc1
@ -1,32 +0,0 @@
|
|||||||
# If applied, this commit will ...
|
|
||||||
|
|
||||||
# Why was this change necessary? Improvements brought about by the
|
|
||||||
# change.
|
|
||||||
|
|
||||||
# End
|
|
||||||
|
|
||||||
# Format
|
|
||||||
# --------------------
|
|
||||||
# (If applied, this commit will...) <subject> (Max 72 char)
|
|
||||||
# |<---- Preferably using up to 50 chars --->|<------------------->|
|
|
||||||
# Example:
|
|
||||||
# Implement automated commit messages
|
|
||||||
|
|
||||||
# (Optional) Explain why this change is being made
|
|
||||||
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
|
|
||||||
|
|
||||||
# (Optional) Provide links or keys to any relevant tickets, articles or other resources
|
|
||||||
# Example: Github issue #23
|
|
||||||
|
|
||||||
# --- COMMIT END ---
|
|
||||||
#
|
|
||||||
# Remember to:
|
|
||||||
# * Capitalize the subject line
|
|
||||||
# * Use the imperative mood in the subject line
|
|
||||||
# * Do not end the subject line with a period
|
|
||||||
# * Separate subject from body with a blank line
|
|
||||||
# * Use the body to explain what and why vs. how
|
|
||||||
# * Can use multiple lines with "-" or "*" for bullet points in body
|
|
||||||
# --------------------
|
|
||||||
|
|
||||||
# Continuous integration messages
|
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +0,0 @@
|
|||||||
*.php text eol=lf diff=php
|
|
||||||
*.css text eol=lf diff=css
|
|
31
MD_STD.php
31
MD_STD.php
@ -378,35 +378,4 @@ final class MD_STD {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a file exists, with one of the expected mime types.
|
|
||||||
*
|
|
||||||
* @param string $filepath File path of the file that needs to exist.
|
|
||||||
* @param string[] $accepted_mimetype Mime type the file should have.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function ensure_file(string $filepath, array $accepted_mimetype = []) {
|
|
||||||
|
|
||||||
if (!\file_exists($filepath)) {
|
|
||||||
throw new MDFileDoesNotExist("File " . basename($filepath) . " does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for mime type follows. If no check is to be done, ignore this.
|
|
||||||
if (empty($accepted_mimetype)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$finfo = \finfo_open(FILEINFO_MIME_TYPE);
|
|
||||||
if (!($mime_type = finfo_file($finfo, $filepath))) {
|
|
||||||
throw new MDWrongFileType("Cannot get mime type of file: " . basename($filepath));
|
|
||||||
}
|
|
||||||
\finfo_close($finfo);
|
|
||||||
|
|
||||||
if (!\in_array($mime_type, $accepted_mimetype)) {
|
|
||||||
throw new MDWrongFileType("Incorrect mime type of file " . \basename($filepath) . ". Mime type is " . \mime_content_type($filepath) . ", accepted any of ['" . \implode("', '", $accepted_mimetype) . "']");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user