public static function getFilenameWithoutExtension($path, $extension = null) { if ('' === $path) { return ''; } Assert::string($path, 'The path must be a string. Got: %s'); Assert::nullOrString($extension, 'The extension must be a string or null. Got: %s'); if (null !== $extension) { // remove extension and trailing dot return rtrim(basename($path, $extension), '.'); } return pathinfo($path, PATHINFO_FILENAME); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The extension must be a string or null. Got: array */ public function testGetFilenameWithoutExtensionFailsIfInvalidExtension() { Path::getFilenameWithoutExtension('/style.css', array()); }