Remove code duplication
parent
62ead24b61
commit
9a1fd450b0
|
@ -85,17 +85,7 @@ class Pool
|
||||||
$name = $package['name'];
|
$name = $package['name'];
|
||||||
$version = $package['version'];
|
$version = $package['version'];
|
||||||
$stability = VersionParser::parseStability($version);
|
$stability = VersionParser::parseStability($version);
|
||||||
if (
|
if ($exempt || $this->isPackageAcceptable($name, $stability)) {
|
||||||
// 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]
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$package['id'] = $id++;
|
$package['id'] = $id++;
|
||||||
$this->packages[] = $package;
|
$this->packages[] = $package;
|
||||||
|
|
||||||
|
@ -154,17 +144,7 @@ class Pool
|
||||||
foreach ($repo->getPackages() as $package) {
|
foreach ($repo->getPackages() as $package) {
|
||||||
$name = $package->getName();
|
$name = $package->getName();
|
||||||
$stability = $package->getStability();
|
$stability = $package->getStability();
|
||||||
if (
|
if ($exempt || $this->isPackageAcceptable($name, $stability)) {
|
||||||
// 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]
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$package->setId($id++);
|
$package->setId($id++);
|
||||||
$this->packages[] = $package;
|
$this->packages[] = $package;
|
||||||
|
|
||||||
|
@ -314,6 +294,21 @@ class Pool
|
||||||
return $prefix.' '.$package->getPrettyString();
|
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)
|
private function ensurePackageIsLoaded($data)
|
||||||
{
|
{
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
|
|
Loading…
Reference in New Issue