<?php
/**
 * Timeframe helper.
 *
 * @package PRECO
 */

namespace PRECO\Includes\Frontend\Engine\Sorting\Preferred;

defined( 'ABSPATH' ) || exit;

/**
 * Timeframe helper.
 */
class TimeframeHelper {
	/**
	 * Convert timeframe key to seconds.
	 *
	 * @param string $timeframe Timeframe.
	 * @return int
	 */
	public function to_seconds( $timeframe ) {
		switch ( (string) $timeframe ) {
			case '':
				return -1;
			case 'last_24h':
				return DAY_IN_SECONDS;
			case 'last_7d':
				return 7 * DAY_IN_SECONDS;
			case 'last_30d':
				return 30 * DAY_IN_SECONDS;
			case 'last_3m':
				return 90 * DAY_IN_SECONDS;
			default:
				return 0;
		}
	}
}
