<?php

namespace CleantalkSP\SpbctWP\Scanner\ScanningLog;

class ScanningLogFacade
{
    /**
     * @param $content
     * @return void
     */
    public static function writeToLog($content)
    {
        Repository::write($content);
    }

    /**
     * @return void
     */
    public static function clearLog()
    {
        Repository::clear();
    }

    /**
     * Render the scanning log
     *
     * @param int $limit
     * @param int $offset
     * @param bool $only_rows
     * @return string
     */
    public static function render(int $limit = 100, int $offset = 0, bool $only_rows = false)
    {
        $data = Repository::getAll($limit, $offset);

        if (!empty($data)) {
            return $only_rows ? Template::generateRows($data) : Template::render($data, $limit);
        }

        return '';
    }

    /**
     * Get data for PDF
     * @psalm-suppress PossiblyUnusedMethod
     */
    public static function getForPDF()
    {
        $data = Repository::getAll();

        if (!empty($data)) {
            return array_reverse($data);
        }
    }
}
