*/
namespace RankMath\Status;
use RankMath\Helper;
use RankMath\Helpers\Str;
defined( 'ABSPATH' ) || exit;
/**
 * Error_Log class.
 */
class Error_Log {
	/**
	 * Log path.
	 *
	 * @var string|bool
	 */
	private $log_path = null;
	/**
	 * File content.
	 *
	 * @var array
	 */
	private $contents = null;
	/**
	 * Display Database/Tables Details.
	 */
	public function display() {
		?>
		
			
			
				WP_DEBUG_LOG'
				);
				?>
			
			can_load() ) {
				$this->display_copy_button();
				$this->display_textarea();
				$this->display_info();
			}
			?>
		
 
		
		
		
		
			get_log_path() ) ); ?>
			(contents ) ) ) ); ?>)
		
		
		
			
			
		
		contents ) ) {
			$wp_filesystem  = Helper::get_filesystem();
			$this->contents = $wp_filesystem->get_contents_array( $this->get_log_path() );
		}
		if ( -1 === $limit ) {
			return join( '', $this->contents );
		}
		return is_array( $this->contents ) ? join( '', array_slice( $this->contents, -$limit ) ) : '';
	}
	/**
	 * Show error if the log cannot be loaded.
	 */
	private function can_load() {
		$log_file      = $this->get_log_path();
		$wp_filesystem = Helper::get_filesystem();
		if (
			empty( $log_file ) ||
			is_null( $wp_filesystem ) ||
			! Helper::is_filesystem_direct() ||
			! $wp_filesystem->exists( $log_file ) ||
			! $wp_filesystem->is_readable( $log_file )
		) {
			?>
			
				
			
			size( $log_file );
		if ( $size > 100000000 ) {
			?>
			
				
			
			log_path ) ) {
			$this->log_path = ini_get( 'error_log' );
		}
		return $this->log_path;
	}
}