$record) { if (!preg_match('~^brands/' . preg_quote($domain, '~') . '/(?:light|dark)\.svg$~D', $record['file'])) throw new RuntimeException('Некорректный путь бренда'); $body = str_replace("\r\n", "\n", file_get_contents($root . '/' . $record['file'])); if (hash('sha256', $body) !== $record['sha256'] || str_contains($body, '' . $brand['label'] . '')) throw new RuntimeException('Не совпал утверждённый готовый SVG: ' . $target); } return $brand; } function prelandBrandState(array $actual, array $brand): int { $expected = array_map(static fn(array $record): string => $record['sha256'], $brand['logos']); if ($actual === $expected) return 0; if (array_keys($actual) !== array_keys($expected)) return 1; foreach ($expected as $path => $hash) { if ($actual[$path] !== $hash && $actual[$path] !== ($brand['replace_from'][$path] ?? null)) return 1; } return 10; }