['before_sha256' => $before, 'after_sha256' => hash('sha256', $source), 'contents' => $source]]; $path = 'app/Modules/Purchasing/BudgetWorkspace.php'; $source = file_get_contents($host.'/'.$path); $before = hash('sha256', $source); $anchor = 'public function command(User $user, string $action, array $input, string $key): array'."\n {"; $source = str_replace("\r\n", "\n", $source); if (substr_count($source, $anchor) !== 1) { throw new \RuntimeException('Workspace orçamental divergente.'); } $source = str_replace($anchor, $anchor."\n if (config('purchasing-operational.enabled') === true) { abort_unless(in_array(\$action, ['create', 'approve'], true), 403, 'Movimentos orçamentais operacionais pertencem ao processo de origem.'); }", $source); $source = str_replace("'synthetic_only' => true", "'synthetic_only' => config('purchasing-operational.enabled') !== true", $source); $result[$path] = ['before_sha256' => $before, 'after_sha256' => hash('sha256', $source), 'contents' => $source]; return $result; } }