added new GPM::getInstallable() method

This commit is contained in:
Andy Miller
2016-08-18 16:03:07 -06:00
parent 560c1c94b4
commit 426ec0cb67

View File

@@ -61,14 +61,36 @@ class GPM extends Iterator
}
/**
* Returns the Locally installed packages
* @return Iterator The installed packages
* Return the locally installed packages
*
* @return Local\Packages
*/
public function getInstalled()
{
return $this->installed;
}
/**
* Returns the Locally installable packages
*
* @param array $list_type_installed
* @return Iterator The installed packages
*/
public function getInstallable($list_type_installed = ['plugins' => true, 'themes' => true])
{
$items = ['total' => 0];
foreach ($list_type_installed as $type => $type_installed) {
if ($type_installed === false) {
continue;
}
$methodInstallableType = 'getInstalled' . ucfirst($type);
$to_install = $this->$methodInstallableType();
$items[$type] = $to_install;
$items['total'] += count($to_install);
}
return $items;
}
/**
* Returns the amount of locally installed packages
* @return integer Amount of installed packages