Skip to content

Commit

Permalink
🐛 fix: Fixed version validation of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermecotaGn committed Oct 27, 2023
1 parent 7a8f9ad commit ae819fc
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions migrationChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
class MigrationChecker
{
private const REQUIRED_PACKAGES = [
'guzzlehttp/guzzle' => '7.4',
'symfony/cache' => '^5.0',
'guzzlehttp/guzzle' => '^7.4',
'symfony/cache' => '^5.0 || ^6.0'
];

private const CORRECTIONS = [
Expand All @@ -23,7 +23,7 @@ class MigrationChecker
'new Gerencianet' => 'new EfiPay',
'Gerencianet::getInstance' => 'EfiPay::getInstance',
'catch (GerencianetException' => 'catch (EfiException',
'oneStep' => 'createOneStepCharge',
'oneStep(' => 'createOneStepCharge(',
'payCharge' => 'definePayMethod',
'resendBillet' => 'sendBilletEmail',
'chageLink' => 'defineLinkPayMethod',
Expand Down Expand Up @@ -61,7 +61,7 @@ public function checkPHPVersion(): array
$resultPhpVersion = [];
$phpVersion = PHP_VERSION;
$resultPhpVersion['version'] = $phpVersion;
if (version_compare($phpVersion, '7.2', '<')) {
if (version_compare($phpVersion, '7.2.5', '<')) {
$resultPhpVersion['result'] = "A versão do PHP instalada <b>NÃO ATENDE</b> aos requisitos. <b>Instale o PHP 7.2 ou superior</b>.";
$resultPhpVersion['icon'] = $this->getIcon('danger');
} else {
Expand Down Expand Up @@ -133,9 +133,18 @@ private function getMissingPackages(): array

foreach ($this->installedPackages['packages'] as $installedPackage) {
if ($installedPackage['name'] === $package) {
if (version_compare($installedPackage['version'], $version, '>=')) {
$packageFound = true;
break;
$installedVersion = $installedPackage['version'];

// Check if the installed version matches any of the allowed versions
$allowedVersions = explode(' || ', $version);
$installedVersion = $this->addVersionPrefix($installedVersion); // Adicionar 'v' se necessário

foreach ($allowedVersions as $allowedVersion) {
$allowedVersion = $this->addVersionPrefix($allowedVersion); // Adicionar 'v' se necessário
if (version_compare($installedVersion, $allowedVersion, '>=')) {
$packageFound = true;
break;
}
}
}
}
Expand All @@ -148,6 +157,14 @@ private function getMissingPackages(): array
return $missingPackages;
}

public function addVersionPrefix($version)
{
if (strpos($version, 'v') === false) {
return 'v' . $version;
}
return $version;
}

public function checkCodeCorrections(): array
{
$corrections = $this->getCorrections();
Expand Down Expand Up @@ -600,4 +617,4 @@ classes e métodos que foram modificados na nova versão da SDK.</p>
<script src="https://getbootstrap.com/docs/5.3/dist/js/bootstrap.bundle.min.js"></script>
</body>

</html>
</html>

0 comments on commit ae819fc

Please sign in to comment.