<commit_before><?php
namespace WFV;
defined( 'ABSPATH' ) or die();

/**
 *
 *
 * @since 0.8.0
 */
class Input implements ValidationInterface {

  use AccessorTrait;
  use MutatorTrait;

  /**
   * __construct
   *
   * @since 0.8.0
   *
   */
  function __construct( $action ) {
    if( $this->is_submit( $action ) ) {
      $this->set( $this->sanitize() );
    }
  }

  /**
   * Sanitize $_POST array
   *
   * @since 0.2.0
   * @since 0.7.2 Returns result, does not set $input property
   * @access protected
   *
   * @return array Sanitized keys and values from $_POST
   */
  protected function sanitize() {
    foreach ( $_POST as $field => $value ) {
      $sane[ sanitize_key( $field ) ] = ( true === is_array( $value ) ) ? $this->sanitize_array( $value ) : sanitize_text_field( $value );
    }
    return $sane;
  }

  /**
   * Sanitize the values of an index array
   *
   * @since 0.8.3
   * @access private
   *
   * @return array Index array of sanitized values
   */
  protected function sanitize_array( $array ) {
    foreach( $array as $input ) {
      $sane_array[] = sanitize_text_field( $input );
    }
    return $sane_array;
  }

  /**
   * Check if there was a $_POST for this action
   *
   * @since 0.7.2
   *
   * @param string $action The forms action value
   * @return bool
   */
  private function is_submit( $action ) {
    return ( $_POST && $_POST['action'] === $action ) ? true : false;
  }
}
<commit_msg>Input - sanitize - yoda condition does nothing here...<commit_after><?php
namespace WFV;
defined( 'ABSPATH' ) or die();

/**
 *
 *
 * @since 0.8.0
 */
class Input implements ValidationInterface {

  use AccessorTrait;
  use MutatorTrait;

  /**
   * __construct
   *
   * @since 0.8.0
   *
   */
  function __construct( $action ) {
    if( $this->is_submit( $action ) ) {
      $this->set( $this->sanitize() );
    }
  }

  /**
   * Sanitize $_POST array
   *
   * @since 0.2.0
   * @since 0.7.2 Returns result, does not set $input property
   * @access protected
   *
   * @return array Sanitized keys and values from $_POST
   */
  protected function sanitize() {
    foreach ( $_POST as $field => $value ) {
      $sane[ sanitize_key( $field ) ] = ( is_array( $value ) ) ? $this->sanitize_array( $value ) : sanitize_text_field( $value );
    }
    return $sane;
  }

  /**
   * Sanitize the values of an index array
   *
   * @since 0.8.3
   * @access private
   *
   * @return array Index array of sanitized values
   */
  protected function sanitize_array( $array ) {
    foreach( $array as $input ) {
      $sane_array[] = sanitize_text_field( $input );
    }
    return $sane_array;
  }

  /**
   * Check if there was a $_POST for this action
   *
   * @since 0.7.2
   *
   * @param string $action The forms action value
   * @return bool
   */
  private function is_submit( $action ) {
    return ( $_POST && $_POST['action'] === $action ) ? true : false;
  }
}

{'fraction_non_alphanumeric': 0.14442916093535077, 'fraction_numerical': 0.012379642365887207, 'mean_word_length': 2.4630952380952382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6666481', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1011, 'n_words': 271}