b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / vendor / composer / composer / src / Composer / SelfUpdate /
Filename/home/dev2.destoffenstraat.com/vendor/composer/composer/src/Composer/SelfUpdate/Versions.php
Size2.54 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified29-Sep-2023 10:50
Last accessed23-Aug-2025 03:56
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Composer\SelfUpdate;

use Composer\Util\RemoteFilesystem;
use Composer\Config;
use Composer\Json\JsonFile;

/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class Versions
{
public static $channels = array('stable', 'preview', 'snapshot', '1', '2');

private $rfs;
private $config;
private $channel;
private $versionsData;

public function __construct(Config $config, RemoteFilesystem $rfs)
{
$this->rfs = $rfs;
$this->config = $config;
}

public function getChannel()
{
if ($this->channel) {
return $this->channel;
}

$channelFile = $this->config->get('home').'/update-channel';
if (file_exists($channelFile)) {
$channel = trim(file_get_contents($channelFile));
if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
return $this->channel = $channel;
}
}

return $this->channel = 'stable';
}

public function setChannel($channel)
{
if (!in_array($channel, self::$channels, true)) {
throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
}

$channelFile = $this->config->get('home').'/update-channel';
$this->channel = $channel;
file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
}

public function getLatest($channel = null)
{
$versions = $this->getVersionsData();

foreach ($versions[$channel ?: $this->getChannel()] as $version) {
if ($version['min-php'] <= PHP_VERSION_ID) {
return $version;
}
}

throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
}

private function getVersionsData()
{
if (!$this->versionsData) {
if ($this->config->get('disable-tls') === true) {
$protocol = 'http';
} else {
$protocol = 'https';
}

$this->versionsData = JsonFile::parseJson($this->rfs->getContents('getcomposer.org', $protocol . '://getcomposer.org/versions', false));
}

return $this->versionsData;
}
}