<?php

namespace App\Services\Filters;


abstract class AbstractFilter
{

    /**
     * @var
     */
    public $builder;

    /**
     * @param $builder
     * @param $params
     * @return mixed
     */
    public function apply($builder, $params)
    {
        $this->builder = $builder;
        foreach ($params as $param => $value) {
            if (method_exists($this, $param) && $value) {
                $this->$param($value);
            }
        }

        return $this->builder;
    }
}

{'avg_line_length': 16.161290322580644, 'max_line_length': 57, 'alphanum_fraction': 0.48303393213572854, 'licenses': ['MIT'], 'repository_name': 'armanbektassov/filter', 'path': 'app/Services/Filters/AbstractFilter.php', 'size': 501, 'lang': 'PHP'}