<?php

namespace KupShop\ElninoBundle\Query;

use Query\Operator;
use Query\QueryBuilder;

class Filter
{
    public static function bySizes(array $sizes)
    {
        return function (QueryBuilder $qb) use ($sizes) {
            return Operator::inStringArray($sizes, 'p.size');
        };
    }

    public static function bySeries(array $seriesNames)
    {
        return function (QueryBuilder $qb) use ($seriesNames) {
            $qb->joinSeriesOnProducts('series');

            return Operator::inStringArray($seriesNames, 'series.name');
        };
    }

    public static function bySex(array $sex)
    {
        return function (QueryBuilder $qb) use ($sex) {
            $qb->joinSeriesOnProducts('series');

            return Operator::inStringArray($sex, 'series.sex');
        };
    }
}
