<?php
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => '008e610a8ac25994e00d0a3697998410e571870c',
'name' => 'brizy/brizy-pro',
),
'versions' =>
array (
'activecampaign/api-php' =>
array (
'pretty_version' => 'v2.0.3',
'version' => '2.0.3.0',
'aliases' =>
array (
),
'reference' => '2bf5b72ba8668de8dcb27e194948028276e748c5',
),
'bagrinsergiu/brizy-forms-sdk' =>
array (
'pretty_version' => '1.2.2',
'version' => '1.2.2.0',
'aliases' =>
array (
),
'reference' => 'e1bd59d4bdcc217172e99a2195f41dd862b331c4',
),
'bagrinsergiu/content-placeholder' =>
array (
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'aliases' =>
array (
),
'reference' => '27b38354235b30a7682b2b0de374746b5605c250',
),
'brizy/brizy-pro' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => '008e610a8ac25994e00d0a3697998410e571870c',
),
'campaignmonitor/createsend-php' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => '12a4c1f33b940775bde80ae1494036df06ed36d4',
),
'drewm/drip' =>
array (
'pretty_version' => 'v0.8',
'version' => '0.8.0.0',
'aliases' =>
array (
),
'reference' => '2f5ebe46dbf82fe16186b8f488ec47a0dd672e37',
),
'drewm/mailchimp-api' =>
array (
'pretty_version' => 'v2.5.4',
'version' => '2.5.4.0',
'aliases' =>
array (
),
'reference' => 'c6cdfab4ca6ddbc3b260913470bd0a4a5cb84c7a',
),
'guzzlehttp/guzzle' =>
array (
'pretty_version' => '6.3.3',
'version' => '6.3.3.0',
'aliases' =>
array (
),
'reference' => '407b0cb880ace85c9b63c5f9551db498cb2d50ba',
),
'guzzlehttp/promises' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '1.4.x-dev',
),
'reference' => '8e7d04f1f6450fef59366c399cfad4b9383aa30d',
),
'guzzlehttp/psr7' =>
array (
'pretty_version' => '1.x-dev',
'version' => '1.9999999.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'dc960a912984efb74d0a90222870c72c87f10c91',
),
'psr/http-message' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '1.0.x-dev',
),
'reference' => 'efd67d1dc14a7ef4fc4e518e7dee91c271d524e4',
),
'psr/http-message-implementation' =>
array (
'provided' =>
array (
0 => '1.0',
),
),
'psr/log' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '1.1.x-dev',
),
'reference' => 'a18c1e692e02b84abbafe4856c3cd7cc6903908c',
),
'ralouphie/getallheaders' =>
array (
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'aliases' =>
array (
),
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
),
'sendinblue/api-v3-sdk' =>
array (
'pretty_version' => 'v6.4.0',
'version' => '6.4.0.0',
'aliases' =>
array (
),
'reference' => '7367053380e9d9a943969289e97d8015e85bb0c9',
),
'symfony/deprecation-contracts' =>
array (
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'aliases' =>
array (
0 => '2.4.x-dev',
),
'reference' => '5f38c8804a9e97d23e0c8d63341088cd8a22d627',
),
'symfony/dotenv' =>
array (
'pretty_version' => '5.x-dev',
'version' => '5.9999999.9999999.9999999-dev',
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => '783f12027c6b40ab0e93d6136d9f642d1d67cd6b',
),
),
);
private static $canGetVendors;
private static $installedByVendor = array();
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
public static function isInstalled($packageName)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return true;
}
}
return false;
}
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
public static function getRawData()
{
return self::$installed;
}
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
}
}
}
$installed[] = self::$installed;
return $installed;
}
}