1
0
Fork 0

Remove code duplication

pull/1015/head
Jordi Boggiano 2012-08-22 17:46:04 +02:00
parent 62ead24b61
commit 9a1fd450b0
1 changed files with 17 additions and 22 deletions

View File

@ -85,17 +85,7 @@ class Pool
$name = $package['name'];
$version = $package['version'];
$stability = VersionParser::parseStability($version);
if (
// always allow exempt repos
$exempt
// allow if package matches the global stability requirement and has no exception
|| (!isset($this->stabilityFlags[$name])
&& isset($this->acceptableStabilities[$stability]))
// allow if package matches the package-specific stability flag
|| (isset($this->stabilityFlags[$name])
&& BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]
)
) {
if ($exempt || $this->isPackageAcceptable($name, $stability)) {
$package['id'] = $id++;
$this->packages[] = $package;
@ -154,17 +144,7 @@ class Pool
foreach ($repo->getPackages() as $package) {
$name = $package->getName();
$stability = $package->getStability();
if (
// always allow exempt repos
$exempt
// allow if package matches the global stability requirement and has no exception
|| (!isset($this->stabilityFlags[$name])
&& isset($this->acceptableStabilities[$stability]))
// allow if package matches the package-specific stability flag
|| (isset($this->stabilityFlags[$name])
&& BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]
)
) {
if ($exempt || $this->isPackageAcceptable($name, $stability)) {
$package->setId($id++);
$this->packages[] = $package;
@ -314,6 +294,21 @@ class Pool
return $prefix.' '.$package->getPrettyString();
}
private function isPackageAcceptable($name, $stability)
{
// allow if package matches the global stability requirement and has no exception
if (!isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability])) {
return true;
}
// allow if package matches the package-specific stability flag
if (isset($this->stabilityFlags[$name]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]) {
return true;
}
return false;
}
private function ensurePackageIsLoaded($data)
{
if (is_array($data)) {