24 lines
780 B
PHP
24 lines
780 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
final class SimulationFiscalSourceAcceptance
|
|
{
|
|
/**
|
|
* @param array<array-key, mixed> $source
|
|
*/
|
|
public static function eligible(array $source, ?string $hash = null): bool
|
|
{
|
|
if (($source['validation_status'] ?? null) === 'validated') {
|
|
return true;
|
|
}
|
|
$basis = $source['fiscal_acceptance'] ?? null;
|
|
|
|
return ($source['validation_status'] ?? null) === 'pending' && is_array($basis)
|
|
&& ($basis['scope'] ?? null) === 'fiscal_parameters'
|
|
&& ($basis['basis'] ?? null) === 'Tempo-official-sources-20261008'
|
|
&& preg_match('/^[a-f0-9]{64}$/D', (string) ($basis['sha256'] ?? '')) === 1
|
|
&& ($hash === null || $basis['sha256'] === $hash);
|
|
}
|
|
}
|