<?php

namespace AutoAdmin\Bundle\Media\Service;

use Exception;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;

class MediaCacheCleaner
{
    private CacheManager $cacheManager;

    public function __construct(CacheManager $cacheManager)
    {
        $this->cacheManager = $cacheManager;
    }

    public function clear($paths = null, $filters = null): bool
    {
        try {
            $this->cacheManager->remove($paths, $filters);
        } catch (Exception $e) {
            return false;
        }

        return true;
    }
}