Files
compras/integrations/sgf/operational/BudgetOverlay.php
T
2026-11-02 08:08:05 +02:00

22 lines
936 B
PHP

<?php
namespace Tempo\Purchasing\Delivery;
final class BudgetOverlay
{
public static function prepare(string $host): array
{
$path = 'app/Modules/Purchasing/BudgetAdapter.php';
$source = file_get_contents($host.'/'.$path);
$before = hash('sha256', $source);
$anchor = "public static function guard(): void\n {";
$source = str_replace("\r\n", "\n", $source);
if (substr_count($source, $anchor) !== 1) {
throw new \RuntimeException('Adaptador orçamental divergente.');
}
$source = str_replace($anchor, $anchor."\n if (config('purchasing-operational.enabled') === true) {\n \\Tempo\\Purchasing\\Delivery\\Installation::assertBudgetReady(DB::connection());\n return;\n }", $source);
return [$path => ['before_sha256' => $before, 'after_sha256' => hash('sha256', $source), 'contents' => $source]];
}
}