34 lines
809 B
PHP
34 lines
809 B
PHP
<?php
|
|
|
|
namespace App\Services\Drift;
|
|
|
|
class DriftHasher
|
|
{
|
|
public function fingerprint(
|
|
int $tenantId,
|
|
string $scopeKey,
|
|
string $subjectType,
|
|
string $subjectExternalId,
|
|
string $changeType,
|
|
string $baselineHash,
|
|
string $currentHash,
|
|
): string {
|
|
$parts = [
|
|
(string) $tenantId,
|
|
$this->normalize($scopeKey),
|
|
$this->normalize($subjectType),
|
|
$this->normalize($subjectExternalId),
|
|
$this->normalize($changeType),
|
|
$this->normalize($baselineHash),
|
|
$this->normalize($currentHash),
|
|
];
|
|
|
|
return hash('sha256', implode('|', $parts));
|
|
}
|
|
|
|
private function normalize(string $value): string
|
|
{
|
|
return trim(mb_strtolower($value));
|
|
}
|
|
}
|