<commit_before><?php
/**
 * CacheProperties.php
 * Copyright (C) 2016 <EMAIL>
 *
 * This software may be modified and distributed under the terms of the
 * Creative Commons Attribution-ShareAlike 4.0 International License.
 *
 * See the LICENSE file for details.
 */

declare(strict_types = 1);

namespace FireflyIII\Support;


use Cache;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection;
use Log;
use Preferences as Prefs;

/**
 * Class CacheProperties
 *
 * @package FireflyIII\Support
 */
class CacheProperties
{

    /** @var  string */
    protected $md5 = '';
    /** @var Collection */
    protected $properties;

    /**
     *
     */
    public function __construct()
    {
        $this->properties = new Collection;
        if (auth()->check()) {
            $this->addProperty(auth()->user()->id);
            $this->addProperty(Prefs::lastActivity());
        }
    }

    /**
     * @param $property
     */
    public function addProperty($property)
    {
        $this->properties->push($property);
    }

    /**
     * @return mixed
     */
    public function get()
    {
        return Cache::get($this->md5);
    }

    /**
     * @return string
     */
    public function getMd5(): string
    {
        return $this->md5;
    }

    /**
     * @return bool
     */
    public function has(): bool
    {
        if (getenv('APP_ENV') == 'testing') {
            Log::debug('APP_ENV is testing, cache disabled.');

            return false;
        }
        $this->md5();

        return Cache::has($this->md5);
    }

    /**
     * @param $data
     */
    public function store($data)
    {
        Cache::forever($this->md5, $data);
    }

    /**
     * @return void<commit_msg>This generates a lot of logging, let’s remove it.<commit_after><?php
/**
 * CacheProperties.php
 * Copyright (C) 2016 <EMAIL>
 *
 * This software may be modified and distributed under the terms of the
 * Creative Commons Attribution-ShareAlike 4.0 International License.
 *
 * See the LICENSE file for details.
 */

declare(strict_types = 1);

namespace FireflyIII\Support;


use Cache;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection;
use Log;
use Preferences as Prefs;

/**
 * Class CacheProperties
 *
 * @package FireflyIII\Support
 */
class CacheProperties
{

    /** @var  string */
    protected $md5 = '';
    /** @var Collection */
    protected $properties;

    /**
     *
     */
    public function __construct()
    {
        $this->properties = new Collection;
        if (auth()->check()) {
            $this->addProperty(auth()->user()->id);
            $this->addProperty(Prefs::lastActivity());
        }
    }

    /**
     * @param $property
     */
    public function addProperty($property)
    {
        $this->properties->push($property);
    }

    /**
     * @return mixed
     */
    public function get()
    {
        return Cache::get($this->md5);
    }

    /**
     * @return string
     */
    public function getMd5(): string
    {
        return $this->md5;
    }

    /**
     * @return bool
     */
    public function has(): bool
    {
        if (getenv('APP_ENV') == 'testing') {
            return false;
        }
        $this->md5();

        return Cache::has($this->md5);
    }

    /**
     * @param $data
     */
    public function store($data)
    {
        Cache::forever($this->md5, $data);
    }

    /**
     * @return void
{'fraction_non_alphanumeric': 0.14350538854225753, 'fraction_numerical': 0.007941009642654566, 'mean_word_length': 2.091148115687993, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '4914921', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1041, 'n_words': 248}