original_string: public static function filter($value, array $field)
      {
          $validate = (array)($field['filter'] ?? $field['validate'] ?? null);
  
          // If value isn't required, we will return null if empty value is given.
          if (($value === null || $value === '') && empty($validate['required'])) {
              return null;
          }
  
          if (!isset($field['type'])) {
              $field['type'] = 'text';
          }
          $type = $field['filter']['type'] ?? $field['validate']['type'] ?? $field['type'];
  
          $method = 'filter' . ucfirst(str_replace('-', '_', $type));
  
          // If this is a YAML field validate/filter as such
          if (isset($field['yaml']) && $field['yaml'] === true) {
              $method = 'filterYaml';
          }
  
          if (!method_exists(__CLASS__, $method)) {
              $method = isset($field['array']) && $field['array'] === true ? 'filterArray' : 'filterText';
          }
  
          return self::$method($value, $validate, $field);
      }
code: public static function filter($value, array $field)
      {
          $validate = (array)($field['filter'] ?? $field['validate'] ?? null);
  
          // If value isn't required, we will return null if empty value is given.
          if (($value === null || $value === '') && empty($validate['required'])) {
              return null;
          }
  
          if (!isset($field['type'])) {
              $field['type'] = 'text';
          }
          $type = $field['filter']['type'] ?? $field['validate']['type'] ?? $field['type'];
  
          $method = 'filter' . ucfirst(str_replace('-', '_', $type));
  
          // If this is a YAML field validate/filter as such
          if (isset($field['yaml']) && $field['yaml'] === true) {
              $method = 'filterYaml';
          }
  
          if (!method_exists(__CLASS__, $method)) {
              $method = isset($field['array']) && $field['array'] === true ? 'filterArray' : 'filterText';
          }
  
          return self::$method($value, $validate, $field);
      }
code_tokens: public static function filter ( $ value , array $ field ) { $ validate = ( array ) ( $ field [ 'filter' ] ?? $ field [ 'validate' ] ?? null ) ; // If value isn't required, we will return null if empty value is given. if ( ( $ value === null || $ value === '' ) && empty ( $ validate [ 'required' ] ) ) { return null ; } if ( ! isset ( $ field [ 'type' ] ) ) { $ field [ 'type' ] = 'text' ; } $ type = $ field [ 'filter' ] [ 'type' ] ?? $ field [ 'validate' ] [ 'type' ] ?? $ field [ 'type' ] ; $ method = 'filter' . ucfirst ( str_replace ( '-' , '_' , $ type ) ) ; // If this is a YAML field validate/filter as such if ( isset ( $ field [ 'yaml' ] ) && $ field [ 'yaml' ] === true ) { $ method = 'filterYaml' ; } if ( ! method_exists ( __CLASS__ , $ method ) ) { $ method = isset ( $ field [ 'array' ] ) && $ field [ 'array' ] === true ? 'filterArray' : 'filterText' ; } return self :: $ method ( $ value , $ validate , $ field ) ; }
docstring: Filter value against a blueprint field definition.
  
  @param  mixed  $value
  @param  array  $field
  @return mixed  Filtered value.
docstring_tokens: Filter value against a blueprint field definition .