*/ private $settings; /** @var array */ private $data; /** @var float */ private $started_at; /** * @param array $settings * @param array $data */ public function __construct(int $run_id, string $run_type, array $settings, array $data) { $this->run_id = $run_id; $this->run_type = $run_type; $this->settings = $settings; $this->data = $data; $this->started_at = microtime(true); } public function run_id(): int { return $this->run_id; } public function run_type(): string { return $this->run_type; } /** * @return array */ public function settings(): array { return $this->settings; } /** * @return array */ public function data(): array { return $this->data; } /** * @param string $key * @param mixed $default * @return mixed */ public function get(string $key, $default = null) { return $this->data[$key] ?? $default; } public function elapsed_ms(): int { return (int) ((microtime(true) - $this->started_at) * 1000); } /** * Build evidence snippet according to settings. */ public function maybe_snippet(string $text, int $max = 1200): string { $ds = $this->settings['data_sharing'] ?? []; $allow = !empty($ds['allow_snippets']); if (!$allow) { return ''; } $max_chars = (int) ($ds['max_snippet_chars'] ?? $max); $max_chars = max(200, min(1200, $max_chars)); return Redactor::redact($text, $max_chars); } }