'^7.4', 'symfony/cache' => '^5.0 || ^6.0' ]; private const CORRECTIONS = [ 'use Gerencianet\Exception\GerencianetException;' => 'use Efi\Exception\EfiException;', 'use Gerencianet\Gerencianet;' => 'use Efi\EfiPay;', 'new Gerencianet' => 'new EfiPay', 'Gerencianet::getInstance' => 'EfiPay::getInstance', 'catch (GerencianetException' => 'catch (EfiException', 'oneStep(' => 'createOneStepCharge(', 'payCharge' => 'definePayMethod', 'resendBillet' => 'sendBilletEmail', 'chageLink' => 'defineLinkPayMethod', 'createChargeBalanceSheet(' => 'defineBalanceSheetBillet(', 'updateParcel' => 'updateCarnetParcel', 'cancelParcel' => 'cancelCarnetParcel', 'resendCarnet' => 'sendCarnetEmail', 'resendParcel' => 'sendCarnetParcelEmail', 'getPlans' => 'listPlans', 'paySubscription' => 'defineSubscriptionPayMethod', 'pixDevolutionGet' => 'pixDetailDevolution', 'pixGetWebhook' => 'pixDetailWebhook', 'pixLocationCreate' => 'pixCreateLocation', 'pixLocationGet' => 'pixDetailLocation', 'pixLocationDeleteTxid' => 'pixUnlinkTxidLocation', 'pixListBalance' => 'getAccountBalance', 'pixUpdateSettings' => 'updateAccountConfig', 'pixListSettings' => 'listAccountConfig', ]; private $rootDirectory; private $composerJson; private $installedPackages; public function __construct() { // Insira abaixo o caminho para os arquivos composer.json e installed.json $this->rootDirectory = __DIR__; $this->composerJson = json_decode(file_get_contents($this->rootDirectory . '/composer.json'), true); $this->installedPackages = json_decode(file_get_contents($this->rootDirectory . '/vendor/composer/installed.json'), true); } public function checkPHPVersion(): array { $resultPhpVersion = []; $phpVersion = PHP_VERSION; $resultPhpVersion['version'] = $phpVersion; if (version_compare($phpVersion, '7.2.5', '<')) { $resultPhpVersion['result'] = "A versão do PHP instalada NÃO ATENDE aos requisitos. Instale o PHP 7.2 ou superior."; $resultPhpVersion['icon'] = $this->getIcon('danger'); } else { $resultPhpVersion['result'] = "A versão do PHP instalada atende aos requisitos."; $resultPhpVersion['icon'] = $this->getIcon('success'); } return $resultPhpVersion; } public function checkSDKInstallation(): array { $resultSdkInfo = []; foreach ($this->installedPackages['packages'] as $package) { if ($package['name'] === 'efipay/sdk-php-apis-efi' || $package['name'] === 'gerencianet/gerencianet-sdk-php') { $packageVersion = $package['version']; if ($package['name'] === 'efipay/sdk-php-apis-efi') { $resultSdkInfo['result'] = "{$package['name']}: $packageVersion"; $resultSdkInfo['icon'] = $this->getIcon('success'); return $resultSdkInfo; } else { $resultSdkInfo['result'] = "Atual: {$package['name']}: $packageVersion
Execute o comando abaixo para instalação da nova SDK da Efí:
composer require efipay/sdk-php-apis-efi"; $resultSdkInfo['icon'] = $this->getIcon('danger'); return $resultSdkInfo; } } } if ($this->composerJson['name'] === 'efipay/sdk-php-apis-efi') { $resultSdkInfo['result'] = "{$this->composerJson['name']}: {$this->composerJson['version']}"; $resultSdkInfo['icon'] = $this->getIcon('success'); return $resultSdkInfo; } return ['result' => '

A SDK de PHP da Efí não está instalada.


Execute o comando abaixo para instalação da nova SDK da Efí:
composer require efipay/sdk-php-apis-efi', 'icon' => $this->getIcon('danger')]; } private function getIcon($status): string { if ($status === 'success') { return ' '; } else { return ' '; } } public function checkRequiredPackages(): array { $missingPackages = $this->getMissingPackages(); if (empty($missingPackages)) { return ['result' => 'Todas as dependências necessárias estão instaladas.', 'icon' => $this->getIcon('success')]; } else { $missingPackagesList = implode('
', $missingPackages); return ['result' => "$missingPackagesList", 'icon' => $this->getIcon('danger')]; } } private function getMissingPackages(): array { $missingPackages = []; foreach (self::REQUIRED_PACKAGES as $package => $version) { $packageFound = false; foreach ($this->installedPackages['packages'] as $installedPackage) { if ($installedPackage['name'] === $package) { $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; } } } } if (!$packageFound) { $missingPackages[] = "$package:$version"; } } return $missingPackages; } public function addVersionPrefix($version) { if (strpos($version, 'v') === false) { return 'v' . $version; } return $version; } public function checkCodeCorrections(): array { $corrections = $this->getCorrections(); if (empty($corrections)) { return ['result' => '

Não foram encontradas correções de código a serem feitas.

', 'icon' => $this->getIcon('success')]; } else { $correctionsList = implode('
', $corrections); return ['result' => "

Foram encontradas as seguintes correções de código a serem feitas:

$correctionsList", 'icon' => $this->getIcon('danger')]; } } private function getCorrections(): array { $corrections = []; foreach ($this->getPhpFiles() as $filePath) { $filename = basename($filePath); if ( strpos($filePath, 'vendor/') !== false || // Ignora arquivos na pasta vendor pathinfo($filename, PATHINFO_EXTENSION) !== 'php' || // Verifica extensão do arquivo $filename === 'migrationChecker.php' // Ignora arquivo migration_checker.php ) { continue; } $content = file_get_contents($filePath); $lines = explode("\n", $content); foreach (self::CORRECTIONS as $incorrect => $correct) { $lineNumber = null; foreach ($lines as $index => $line) { if (strpos($line, $incorrect) !== false) { $lineNumber = $index + 1; break; } } if ($lineNumber !== null) { $corrections[] = "

Na linha $lineNumber, do arquivo: $filePath. Substituir $incorrect por $correct
"; } } } return $corrections; } private function getPhpFiles(): array { $phpFiles = []; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->rootDirectory)); foreach ($iterator as $file) { if ($file->isFile() && $file->getExtension() === 'php' && $file->getFilename() !== 'migration_checker.php') { $phpFiles[] = $file->getPathname(); } } return $phpFiles; } } $checker = new MigrationChecker(); ?> SDK PHP Migration Checker Check

Validador de Migração SDK PHP

O Validador de Migração da SDK Efí Pay é uma ferramenta desenvolvida para facilitar o processo de atualização da sua integração com a nova SDK de PHP da Efí Pay. Essa ferramenta analisa o seu código existente em busca de padrões específicos relacionados a classes e métodos que foram modificados na nova versão da SDK.

Atualizar resultados
checkPHPVersion(); ?>

Versão do PHP

checkSDKInstallation(); ?>

Versao da SDK

checkRequiredPackages(); ?>

Dependências necessárias

checkCodeCorrections(); ?>

Resultados