Returns the extension from a file path.
public static getExtension ( string $path, boolean $forceLowerCase = false ) : string | ||
$path | string | The path string. |
$forceLowerCase | boolean | Forces the extension to be lower-case (requires mbstring extension for correct multi-byte character handling in extension). |
return | string | The extension of the file path (without leading dot). |
/** * {@inheritdoc} */ public function guess($path) { $ext = Path::getExtension($path, true); if ('' == trim($ext)) { return null; } return isset($this->mimes[$ext]) ? $this->mimes[$ext] : null; }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The path must be a string. Got: array */ public function testGetExtensionFailsIfInvalidPath() { Path::getExtension(array()); }
/** * Returns true if the file matched any given extension (case-insensitive) * @param $path * @param array $extension * @return bool */ public static function matchExt($path, array $extension) { return in_array(Path::getExtension($path, true), $extension); }