<commit_before><?php

namespace Imanghafoori\Widgets\Utils\Normalizers;

use Imanghafoori\Widgets\Utils\NormalizerContract;

class CacheNormalizer implements NormalizerContract
{
    /**
     * ّFigures out how long the cache life time should be.
     *
     * @param object $widget
     * @return void
     */
    public function normalize($widget): void
    {
        if (! property_exists($widget, 'cacheLifeTime')) {
            $M = (int) (config('widgetize.default_cache_lifetime', 0));
            $widget->cacheLifeTime = new \DateInterval('PT'.$M.'M');
        }

        if ($widget->cacheLifeTime === 'forever' || $widget->cacheLifeTime < 0) {
            // 2 weeks which is long enough !
            $widget->cacheLifeTime = new \DateInterval('P2W');
        } elseif (is_numeric($widget->cacheLifeTime)) {
            $widget->cacheLifeTime = new \DateInterval('PT'.(string)$widget->cacheLifeTime.'M');
        }
    }
}<commit_msg>Apply fixes from StyleCI<commit_after><?php

namespace Imanghafoori\Widgets\Utils\Normalizers;

use Imanghafoori\Widgets\Utils\NormalizerContract;

class CacheNormalizer implements NormalizerContract
{
    /**
     * ّFigures out how long the cache life time should be.
     *
     * @param object $widget
     * @return void
     */
    public function normalize($widget): void
    {
        if (! property_exists($widget, 'cacheLifeTime')) {
            $M = (int) (config('widgetize.default_cache_lifetime', 0));
            $widget->cacheLifeTime = new \DateInterval('PT'.$M.'M');
        }

        if ($widget->cacheLifeTime === 'forever' || $widget->cacheLifeTime < 0) {
            // 2 weeks which is long enough !
            $widget->cacheLifeTime = new \DateInterval('P2W');
        } elseif (is_numeric($widget->cacheLifeTime)) {
            $widget->cacheLifeTime = new \DateInterval('PT'.(string) $widget->cacheLifeTime.'M');
        }
    }
}
{'fraction_non_alphanumeric': 0.13970588235294118, 'fraction_numerical': 0.004201680672268907, 'mean_word_length': 2.7279843444227008, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '7138168', 'n_tokens_mistral': 569, 'n_tokens_neox': 562, 'n_words': 118}