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

use WFV\ValidationInterface;

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

  /**
   * __construct
   *
   * @since 0.8.0
   * @since 0.9.0 Sanitize $_POST moved
   *
   */
  function __construct( $action ) {
    if( $this->is_submit( $action ) ) {
      $this->copy_input();
    }
  }

  /**
   *
   *
   * @since 0.9.0
   *
   * @param string $field
   * @param string|array (optional) $callback
   * @return string|null
   */
  public function render( $field, $callback = 'htmlspecialchars' ) {
    if( is_string( $field ) ) {
      return ( $this->has( $field ) ) ? $this->call_func( $callback, $this->$field ) : null;
    }
    return null;
  }

  /**
   * Transform a string or array leafs using a callback.<commit_msg>Input - has method temp placement while WIP<commit_after><?php
namespace WFV\Component;
defined( 'ABSPATH' ) or die();

use WFV\ValidationInterface;

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

  /**
   * __construct
   *
   * @since 0.8.0
   * @since 0.9.0 Sanitize $_POST moved
   *
   */
  function __construct( $action ) {
    if( $this->is_submit( $action ) ) {
      $this->copy_input();
    }
  }

  /**
   * Check if property exists
   *
   * @since 0.8.0
   *
   * @param string $property
   * @return bool
   */
  private function has( $property ) {
    return ( true === property_exists( $this, $property ) ) ? true : false;
  }


  /**
   *
   *
   * @since 0.9.0
   *
   * @param string $field
   * @param string|array (optional) $callback
   * @return string|null
   */
  public function render( $field, $callback = 'htmlspecialchars' ) {
    if( is_string( $field ) ) {
      return ( $this->has( $field ) ) ? $this->call_func( $callback, $this->$field ) : null;
    }
    return null;
  }

  /**
   * Transform a string or array leafs using a callback.
{'fraction_non_alphanumeric': 0.15830315571650286, 'fraction_numerical': 0.01396792550439731, 'mean_word_length': 2.472172351885099, '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': '5796309', 'n_tokens_mistral': 695, 'n_tokens_neox': 673, 'n_words': 163}