<?php
/**
 * Error log writer implementation.
 *
 * @package Awesomemotive\Rewardswp\Logging\Writers
 * @since 1.1.0
 */

namespace Awesomemotive\Rewardswp\Logging\Writers;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Awesomemotive\Rewardswp\Interfaces\LogWriterInterface;

/**
 * Writes log entries using PHP's error_log for fallback compatibility.
 *
 * @since 1.1.0
 */
class ErrorLogWriter implements LogWriterInterface {
	/**
	 * Write a log entry using PHP's error_log.
	 *
	 * @since 1.1.0
	 *
	 * @param string $level   Log level.
	 * @param string $message Log message.
	 * @param array  $context Contextual data (unused).
	 */
	public function write( string $level, string $message, array $context = [] ): void {
		$formatted = sprintf(
			'RewardsWP [%s] %s',
			strtoupper( $level ),
			$message
		);

		error_log( $formatted ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
	}
}
