<commit_before><?php

namespace San4io\EloquentFilter\Traits;

use Illuminate\Database\Eloquent\Builder;
use San4io\EloquentFilter\Filters\AbstractFilter;

trait Filterable
{
    /**
     * @param Builder $query
     * @param array $data
     * @return \Illuminate\Database\Query\Builder
     */
    public function scopeFilter(Builder $query, array $data = [])
    {
        $filters = $this->getFilterable();

        foreach ($data as $key => $value) {
            if (in_array($key, array_keys($filters))) {
                /** @var AbstractFilter $filter */
                $filter = new $filters[$key]($query);
                $query = $filter->filter($key, $value);
            }
        }

        return $query;
    }

    /**
     * @return array
     */
    public function getFilterable(): array
    {<commit_msg>last type<commit_after><?php

namespace San4io\EloquentFilter\Traits;

use Illuminate\Database\Eloquent\Builder;
use San4io\EloquentFilter\Filters\AbstractFilter;

trait Filterable
{
    /**
     * @param Builder $query
     * @param array $data
     * @return Builder
     */
    public function scopeFilter(Builder $query, array $data = [])
    {
        $filters = $this->getFilterable();

        foreach ($data as $key => $value) {
            if (in_array($key, array_keys($filters))) {
                /** @var AbstractFilter $filter */
                $filter = new $filters[$key]($query);
                $query = $filter->filter($key, $value);
            }
        }

        return $query;
    }

    /**
     * @return array
     */
    public function getFilterable(): array
    {
{'fraction_non_alphanumeric': 0.13712168004941322, 'fraction_numerical': 0.0024706609017912293, 'mean_word_length': 2.1153846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5077924', 'n_tokens_mistral': 483, 'n_tokens_neox': 482, 'n_words': 101}