/**
  * @param ISurveyStep $current_step
  * @param ISurveyQuestionTemplate $question
  * @param array $static_rules
  * @param FormField $field
  */
 public function apply(ISurveyStep $current_step, ISurveyQuestionTemplate $question, array $static_rules, FormField $field)
 {
     if (count($static_rules)) {
         foreach ($static_rules as $id => $info) {
             $q = $info['question'];
             $values = $info['values'];
             $operator = $info['operator'];
             $visibility = $info['visibility'];
             $default = $info['default'];
             $boolean_operator = $info['boolean_operator'];
             $initial_condition = $info['initial_condition'];
             $answer = $current_step->survey()->findAnswerByQuestion($q);
             if (is_null($answer)) {
                 continue;
             }
             //checks the condition
             switch ($operator) {
                 case 'Equal':
                     foreach ($values as $vid) {
                         if ($boolean_operator === 'And') {
                             $initial_condition &= strpos($answer->value(), $vid) !== false;
                         } else {
                             $initial_condition |= strpos($answer->value(), $vid) !== false;
                         }
                     }
                     break;
                 case 'Not-Equal':
                     foreach ($values as $vid) {
                         if ($boolean_operator === 'And') {
                             $initial_condition &= strpos($answer->value(), $vid) === false;
                         } else {
                             $initial_condition |= strpos($answer->value(), $vid) === false;
                         }
                     }
                     break;
             }
             //visibility
             switch ($visibility) {
                 case 'Visible':
                     if (!$initial_condition) {
                         $field->addExtraClass('hidden');
                         // if not visible clean it
                         $field->setValue('');
                     } else {
                         $field->removeExtraClass('hidden');
                     }
                     break;
                 case 'Not-Visible':
                     if ($initial_condition) {
                         $field->addExtraClass('hidden');
                         // if not visible clean it
                         $field->setValue('');
                     } else {
                         $field->removeExtraClass('hidden');
                     }
                     break;
             }
             // set the default value set on the rule
             if (!empty($default)) {
                 $field->setValue($default);
                 if ($question instanceof IMultiValueQuestionTemplate) {
                     $value_template = $question->getValueByValue($default);
                     if (!is_null($value_template)) {
                         $field->setValue($value_template->getIdentifier());
                     }
                 }
             }
         }
     }
 }