<commit_before><?php

namespace Kordy\Ticketit\Models;

use Cache;
use Illuminate\Database\Eloquent\Model;
use Kordy\Ticketit\Models\Setting as Table;

class Setting extends Model
{
    /**
     * @var array
     */
    protected $fillable = ['lang', 'slug', 'value', 'default'];
    /**
     * @var string
     */
    protected $table = 'ticketit_settings';

    /**
     * Returns one of three columns by slug.
     * Priority: lang, value, default.
     *
     * @param $query
     * @param $slug
     *
     * @return mixed
     */
    public function scopeBySlug($query, $slug)
    {
        return $query->whereSlug($slug);
    }

    /**
     * Grab a setting from cached Settings table by slug.
     * Cache lifetime: 60 minutes.
     *
     * @param $slug
     *
     * @return mixed
     */
    public static function grab($slug)
    {
        /*
         * Comment out prior to 0.2 launch. Will cause massive amount
         * of Database queries. Only for adding new settings while
         * in development and testing.
         */
        //Cache::forget('settings');

        // Check if config file has the requested setting, return its value overriding the db settings
        if(config("ticketit.$slug")) {
            if (config("ticketit.$slug") == 'yes') {
                return true;
            }

            if (config("ticketit.$slug") == 'no') {
                return false;
            }
            return config("ticketit.$slug");
        }

        $settings = Cache::remember('settings', 60, function () {
            return Table::all();
        });

        $setting = $settings->where('slug', $slug)->first();

        if ($setting->lang) {
            return trans($setting->lang);
        }

        if (self::is_serialized($setting->value)) {
            $setting = unserialize($setting->value);
        } else {
            $setting = $setting->value;
        }

        return $setting;<commit_msg>Applied fixes from StyleCI<commit_after><?php

namespace Kordy\Ticketit\Models;

use Cache;
use Illuminate\Database\Eloquent\Model;
use Kordy\Ticketit\Models\Setting as Table;

class Setting extends Model
{
    /**
     * @var array
     */
    protected $fillable = ['lang', 'slug', 'value', 'default'];
    /**
     * @var string
     */
    protected $table = 'ticketit_settings';

    /**
     * Returns one of three columns by slug.
     * Priority: lang, value, default.
     *
     * @param $query
     * @param $slug
     *
     * @return mixed
     */
    public function scopeBySlug($query, $slug)
    {
        return $query->whereSlug($slug);
    }

    /**
     * Grab a setting from cached Settings table by slug.
     * Cache lifetime: 60 minutes.
     *
     * @param $slug
     *
     * @return mixed
     */
    public static function grab($slug)
    {
        /*
         * Comment out prior to 0.2 launch. Will cause massive amount
         * of Database queries. Only for adding new settings while
         * in development and testing.
         */
        //Cache::forget('settings');

        // Check if config file has the requested setting, return its value overriding the db settings
        if (config("ticketit.$slug")) {
            if (config("ticketit.$slug") == 'yes') {
                return true;
            }

            if (config("ticketit.$slug") == 'no') {
                return false;
            }

            return config("ticketit.$slug");
        }

        $settings = Cache::remember('settings', 60, function () {
            return Table::all();
        });

        $setting = $settings->where('slug', $slug)->first();

        if ($setting->lang) {
            return trans($setting->lang);
        }

        if (self::is_serialized($setting->value)) {
            $setting = unserialize($setting->value);
        } else {
            $setting = $setting->value;
        }

        return $setting;
{'fraction_non_alphanumeric': 0.1324775353016688, 'fraction_numerical': 0.0030808729139922978, 'mean_word_length': 1.810966810966811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '7211809', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1083, 'n_words': 295}