# force-refresh/2.10.1/includes/services/classes/class-debug-storage-service.php

Force Refresh, version 2.10.1. 57 lines.

- Page: https://pluginprobe.com/plugins/force-refresh/2.10.1/code/includes/services/classes/class-debug-storage-service.php
- Raw: https://pluginprobe.com/plugins/force-refresh/2.10.1/raw/includes/services/classes/class-debug-storage-service.php
- Modified: 2023-11-10T16:53:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/force-refresh/2.10.1/code/includes/services/classes/class-debug-storage-service.php#L10-L20`.

```php
<?php
/**
 * Our class responsible for debug storage services.
 *
 * @package ForceRefresh
 */

namespace JordanLeven\Plugins\ForceRefresh\Services;

/**
 * Class for debug storage services.
 */
class Debug_Storage_Service {

    const OPTION_DEBUG_ACTIVE_DATE = 'force_refresh_debug_active_date';

    const DEBUG_MODE_ACTIVE_IN_HOURS = 48;

    /**
     * Method for getting the current debug mode.
     *
     * @return  bool    True if debug is active.
     */
    public static function debug_mode_is_active(): bool {
        $debug_active_date = (string) get_option( self::OPTION_DEBUG_ACTIVE_DATE, '' );

        if ( ! $debug_active_date ) {
            return false;
        }

        $time_current = strtotime( current_time( 'mysql' ) );
        $time_debug   = strtotime( $debug_active_date );

        $difference_in_hours = abs( $time_current - $time_debug ) / 3600;
        return $difference_in_hours < self::DEBUG_MODE_ACTIVE_IN_HOURS;
    }

    /**
     * Method for saving the debug mode.
     *
     * @param bool $debug_mode True if debug mode should be turned on.
     *
     * @return void
     */
    public static function set_debug_mode( bool $debug_mode ): void {
        if ( $debug_mode ) {
            $time = current_time( 'mysql' );
            update_option(
                self::OPTION_DEBUG_ACTIVE_DATE,
                $time
            );
        } else {
            delete_option( self::OPTION_DEBUG_ACTIVE_DATE );
        }
    }
}

```
