original_string: protected function getValidator(array $options, $required, $optionValueIsAnswer)
      {
          // @codingStandardsIgnoreStart
          if ($options) {
              $useValue = $this->isList($options) && $optionValueIsAnswer;
  
              return function ($value) use ($options, $useValue) {
                  if ($useValue && !array_key_exists($value, $options)
                      || !$useValue && !in_array($value, $options, true)
                  ) {
                      throw new LogicException("Incorrect value '$value'.");
                  }
  
                  return $useValue ? $options[$value] : $value;
              };
          } else {
              return function ($value) use ($required) {
                  if ($required && (null === $value)) {
                      throw new LogicException('Empty value.');
                  }
  
                  return $value;
              };
          }
          // @codingStandardsIgnoreEnd
      }
code: protected function getValidator(array $options, $required, $optionValueIsAnswer)
      {
          // @codingStandardsIgnoreStart
          if ($options) {
              $useValue = $this->isList($options) && $optionValueIsAnswer;
  
              return function ($value) use ($options, $useValue) {
                  if ($useValue && !array_key_exists($value, $options)
                      || !$useValue && !in_array($value, $options, true)
                  ) {
                      throw new LogicException("Incorrect value '$value'.");
                  }
  
                  return $useValue ? $options[$value] : $value;
              };
          } else {
              return function ($value) use ($required) {
                  if ($required && (null === $value)) {
                      throw new LogicException('Empty value.');
                  }
  
                  return $value;
              };
          }
          // @codingStandardsIgnoreEnd
      }
code_tokens: protected function getValidator ( array $ options , $ required , $ optionValueIsAnswer ) { // @codingStandardsIgnoreStart if ( $ options ) { $ useValue = $ this -> isList ( $ options ) && $ optionValueIsAnswer ; return function ( $ value ) use ( $ options , $ useValue ) { if ( $ useValue && ! array_key_exists ( $ value , $ options ) || ! $ useValue && ! in_array ( $ value , $ options , true ) ) { throw new LogicException ( "Incorrect value '$value'." ) ; } return $ useValue ? $ options [ $ value ] : $ value ; } ; } else { return function ( $ value ) use ( $ required ) { if ( $ required && ( null === $ value ) ) { throw new LogicException ( 'Empty value.' ) ; } return $ value ; } ; } // @codingStandardsIgnoreEnd }
docstring: Get value validator
  
  @param array $options
  @param bool  $required
  @param bool  $optionValueIsAnswer Value from options should be considered as an answer
  @return \Closure
  @throws LogicException
docstring_tokens: Get value validator