mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Rename findPackagesByName to findPackages and allow version arg
This commit is contained in:
parent
afbb9cefa4
commit
5eb333680b
7 changed files with 63 additions and 36 deletions
|
@ -44,14 +44,21 @@ class ArrayRepository implements RepositoryInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findPackagesByName($name)
|
||||
public function findPackages($name, $version = null)
|
||||
{
|
||||
// normalize name
|
||||
$name = strtolower($name);
|
||||
|
||||
// normalize version
|
||||
if (null !== $version) {
|
||||
$versionParser = new VersionParser();
|
||||
$version = $versionParser->normalize($version);
|
||||
}
|
||||
|
||||
$packages = array();
|
||||
|
||||
foreach ($this->getPackages() as $package) {
|
||||
if ($package->getName() === $name) {
|
||||
if ($package->getName() === $name && (null === $version || $version === $package->getVersion())) {
|
||||
$packages[] = $package;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue