Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* add extension to getFilename() so we don't need to switch in there…

… (HT, @naderman)
  • Loading branch information...
commit 2b50046a401f1947feeb94ec2318bc590ff6bab4 1 parent c9b1ebf
@till authored
Showing with 6 additions and 16 deletions.
  1. +6 −16 src/Composer/Package/Dumper/BaseDumper.php
View
22 src/Composer/Package/Dumper/BaseDumper.php
@@ -75,27 +75,17 @@ public function __construct($path = null)
/**
* @param \Composer\Package\PackageInterface $package
+ * @param string $extension
*
* @return string
* @throws \InvalidArgumentException When unknown 'format' is encountered.
*/
- public function getFilename(PackageInterface $package)
+ public function getFilename(PackageInterface $package, $extension)
{
- switch ($this->format) {
- case 'tarball':
- $ext = 'tar';
- break;
- case 'zip':
- $ext = 'zip';
- break;
- default:
- throw new \InvalidArgumentException("Format '{$this->format}' is not supported.");
- }
-
- $fileName = sprintf('%s-%s.%s',
- $package->getPrettyName(),
- $package->getVersion(),
- $ext
+ $name = preg_replace('[^a-z0-9_-]', '-', $package->getUniqueName());
+ $fileName = sprintf('%s.%s',
+ $name,
+ $extension
);
return $fileName;
}

0 comments on commit 2b50046

Please sign in to comment.
Something went wrong with that request. Please try again.