<?php

declare(strict_types=1);

namespace KupShop\MetricsBundle\StatusProviders;

use KupShop\KupShopBundle\Metrics\AbstractStatusProvider;
use KupShop\KupShopBundle\Metrics\StatusSample;

class CacheStatusProvider extends AbstractStatusProvider
{
    public function getData(): StatusSample|iterable
    {
        $status = 1;
        $val = rand();

        setCache('status_test', $val);

        if (getCache('status_test') != $val) {
            $status = 0;
        }

        clearCache('status_test');

        if (getCache('status_test') !== false) {
            $status = 0;
        }

        return new StatusSample('cache', $status);
    }
}
