<commit_before><?php

namespace Becklyn\AssetsBundle\Asset;

use Becklyn\AssetsBundle\Exception\AssetsException;
use Psr\Cache\CacheItemPoolInterface;


/**
 * The main cache handler for assets
 */
class AssetsCache
{
    const CACHE_KEY = "becklyn.assets.cache";


    /**
     * @var array<string, Asset>
     */
    private $assets = [];


    /**
     * @param CacheItemPoolInterface $pool
     * @throws \Psr\Cache\InvalidArgumentException
     */
    public function __construct (CacheItemPoolInterface $pool)
    {
        $this->cacheItem = $pool->getItem(self::CACHE_KEY);
        $this->cachePool = $pool;
        $this->assets = $this->cacheItem->isHit() ? $this->cacheItem->get() : [];
    }


    /**
     * Returns the cached asset
     *
     * @param string $assetPath
     *
     * @return Asset|null<commit_msg>Add missing properties<commit_after><?php

namespace Becklyn\AssetsBundle\Asset;

use Becklyn\AssetsBundle\Exception\AssetsException;
use Psr\Cache\CacheItemPoolInterface;


/**
 * The main cache handler for assets
 */
class AssetsCache
{
    const CACHE_KEY = "becklyn.assets.cache";


    /**
     * @var CacheItemPoolInterface
     */
    private $cachePool;


    /**
     * @var \Psr\Cache\CacheItemInterface
     */
    private $cacheItem;


    /**
     * @var array<string, Asset>
     */
    private $assets = [];


    /**
     * @param CacheItemPoolInterface $pool
     * @throws \Psr\Cache\InvalidArgumentException
     */
    public function __construct (CacheItemPoolInterface $pool)
    {
        $this->cachePool = $pool;
        $this->cacheItem = $pool->getItem(self::CACHE_KEY);
        $this->assets = $this->cacheItem->isHit() ? $this->cacheItem->get() : [];
    }


    /**
     * Returns the cached asset
     *
     * @param string $assetPath
     *
     * @return Asset|null
{'fraction_non_alphanumeric': 0.1362144420131291, 'fraction_numerical': 0.0, 'mean_word_length': 2.6146245059288535, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2445651', 'n_tokens_mistral': 574, 'n_tokens_neox': 553, 'n_words': 107}