<commit_before><?php
/**
 * FilterQuery.php
 *
 * @since 19/01/17
 * @author gseidel
 */

namespace Enhavo\Bundle\AppBundle\Filter;


class FilterQuery
{
    const OPERATOR_EQUALS = '=';
    const OPERATOR_LIKE = 'like';

    const ORDER_ASC = 'asc';
    const ORDER_DESC = 'desc';

    /**
     * @var array
     */
    private $where = [];

    /**
     * @var array
     */
    private $orderBy = [];

    public function addOrderBy($property, $order)
    {
        $this->orderBy[] = [
            'property' => $property,
            'order' => $order
        ];
    }

    public function addWhere($property, $operator, $value, $joinProperty = null)
    {
        $this->where[] = [
            'property' => $property,
            'operator' => $operator,
            'value' => $value,
            'joinProperty' => $joinProperty
        ];
    }

    public function getWhere()
    {
        return $this->where;<commit_msg>add remove methods to filter query<commit_after><?php
/**
 * FilterQuery.php
 *
 * @since 19/01/17
 * @author gseidel
 */

namespace Enhavo\Bundle\AppBundle\Filter;


class FilterQuery
{
    const OPERATOR_EQUALS = '=';
    const OPERATOR_LIKE = 'like';

    const ORDER_ASC = 'asc';
    const ORDER_DESC = 'desc';

    /**
     * @var array
     */
    private $where = [];

    /**
     * @var array
     */
    private $orderBy = [];

    public function addOrderBy($property, $order)
    {
        $this->orderBy[] = [
            'property' => $property,
            'order' => $order
        ];
    }

    public function removeOrderBy($property, $order)
    {
        if(!$property && !$order){
            return;
        }
        foreach ($this->orderBy as $index => $orderBy){
            if($property && $orderBy['property'] !== $property){
                continue;
            }
            if($order && $orderBy['operator'] !== $order){
                continue;
            }
            unset($this->orderBy[$index]);
        }
    }

    public function addWhere($property, $operator, $value, $joinProperty = null)
    {
        $this->where[] = [
            'property' => $property,
            'operator' => $operator,
            'value' => $value,
            'joinProperty' => $joinProperty
        ];
    }

    public function removeWhere($property, $operator, $value, $joinProperty = null)
    {
        if(!$property && !$operator && !$value && !$joinProperty){
            return;
        }
        foreach ($this->where as $index => $where){
            if($property && $where['property'] !== $property){
                continue;
            }
            if($operator && $where['operator'] !== $operator){
                continue;
            }
            if($value && $where['value'] !== $value){
                continue;
            }
            if($joinProperty && $where['joinProperty'] !== $joinProperty){
                continue;
            }
            unset($this->where[$index]);
        }
    }

    public function getWhere()
    {
        return $this->where;
{'fraction_non_alphanumeric': 0.15675320407492607, 'fraction_numerical': 0.003943476832073612, 'mean_word_length': 1.71301247771836, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '4037257', 'n_tokens_mistral': 897, 'n_tokens_neox': 867, 'n_words': 177}