<?php

namespace Simplyin\Simplyin_W_Plugin\Helper;

final class Log_Sanitizer {

	private const SENSITIVE_KEYS = [
		'auth_token',
		'authToken',
		'notification_token_id',
		'notificationTokenId',
		'merchantToken',
		'apiKey',
		'api_key',
		'merchantApiKey',
		'X-Auth-Merchant-Api-Key',
	];

	public static function mask( array $data ): array {
		array_walk_recursive( $data, static function ( &$value, $key ) {
			if ( in_array( $key, self::SENSITIVE_KEYS, true ) && ! empty( $value ) ) {
				$value = '[REDACTED]';
			}
		} );
		return $data;
	}
}
