<commit_before><?php

namespace Gaaarfild\LaravelConf;

use Illuminate\Support\Traits\Macroable;

class Conf
{

    use Macroable;


    public function __construct()
    {

    }

    /**
     * Return config value by key
     *
     * @param $key
     * @param bool $default
     * @return string
     */
    public function get($key, $default=false)
    {
        return 'ok';
    }

}<commit_msg>added methods<commit_after><?php

namespace Gaaarfild\LaravelConf;

use Illuminate\Support\Traits\Macroable;
use Session;
use Config;

/**
 * Class Conf
 * @package Gaaarfild\LaravelConf
 */
class Conf
{

    use Macroable;

    /**
     * In-memory config store
     *
     * @var \Illuminate\Support\Collection|null
     */
    private $config = null;

    /**
     * File to save config file
     *
     * @var null|string
     */
    private $file = null;

    /**
     * Create new instance of Conf class
     */
    public function __construct()
    {
        $this->file = storage_path('app/conf.json');
        if (empty($this->config)) {
            if (!file_exists($this->file)) {
                file_put_contents($this->file, json_encode([]));
            }
            $this->config = collect(json_decode(file_get_contents($this->file), true));
        }
    }

    /**
     * Store config value by key
     *
     * @param $key
     * @param $value
     */
    public function set($key, $value)
    {
        $this->config->put($key, $value);
        file_put_contents($this->file, $this->config->toJson());
    }

    /**
     * Check existence of the key
     *
     * @param $key
     * @param bool $withFallback
     * @return string
     */
    public function has($key, $withFallback=false)
    {
        $has = $this->config->has($hey);
        if($withFallback) {
            return $has;
        } else {
            if ($has) {
                return $has;
            } else {
                return Config::has($key);
            }
        }
    }

    /**
     * Get config value by key
     *
     * @param $key
     * @param bool $default
     * @return string
     */
    public function get($key, $default=null)
    {
        return $this->config->get($key, Config::get($key, $default));
    }

    /**
     * Return entire config
     * @return string
     */
    public function all()
    {
        return $this->config->all();
    }

}
{'fraction_non_alphanumeric': 0.13839662447257384, 'fraction_numerical': 0.0, 'mean_word_length': 1.7634032634032635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '1143136', 'n_tokens_mistral': 747, 'n_tokens_neox': 730, 'n_words': 162}