/**
  * @param Criteria $criteria
  */
 public function decorate(Criteria $criteria)
 {
     $alcoholFrom = $this->form->get('alcohol')->get('from')->getData();
     $alcoholTo = $this->form->get('alcohol')->get('to')->getData();
     if (!is_null($alcoholFrom)) {
         $criteria->withAlcoholContentGreaterThan($alcoholFrom);
     }
     if (!is_null($alcoholTo)) {
         $criteria->withAlcoholContentLowerThan($alcoholTo);
     }
     $criteria->addQuery($this->form->get('query')->getData());
     $criteria->mustContainIngredients($this->form->get('ingredients')->getData());
     $tasteBuilder = new TasteBuilder();
     foreach ($this->form->get('taste')->getData() as $tasteName) {
         switch ($tasteName) {
             case Tastes::SWEET:
                 $tasteBuilder->sweet();
                 break;
             case Tastes::BITTER:
                 $tasteBuilder->bitter();
                 break;
             case Tastes::SALTY:
                 $tasteBuilder->salty();
                 break;
             case Tastes::SPICY:
                 $tasteBuilder->spicy();
                 break;
             case Tastes::SOUR:
                 $tasteBuilder->sour();
                 break;
         }
     }
     $criteria->updateRequiredTaste($tasteBuilder->buildTaste());
 }
 function it_build_parameters_with_alcohol_content_range()
 {
     $criteria = new Criteria(0, false);
     $criteria->withAlcoholContentLowerThan(100);
     $criteria->withAlcoholContentGreaterThan(0);
     $this->createParameters($criteria)->shouldReturn(['index' => ElasticSearch::INDEX, 'type' => 'recipe', 'body' => ['from' => 0, 'size' => 10, 'query' => ['filtered' => ['filter' => ['and' => [['range' => ['description.alcoholContent' => ['gte' => 0, 'lte' => 100]]]]]]]]]);
 }