<commit_before><?php namespace MagicMetaBox;

class MagicMetaBox {

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $id = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $title = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var array
     */
    protected $screens = array();

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $prefix = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $metaName = '';

    /**
     * @since 1.0.0
     * @access private
     * @var array
     */
    private $fields = array();

    /**
     * Initialize the class and set its properties.
     *
     * @since 1.0.0
     * @param string $id
     * @param string $title
     * @param array $screens
     * @param string $prefix
     */
    public function __construct( $id, $title, $screens, $prefix ) {
        $this->id = $id;
        $this->title = $title;
        $this->screens = $screens;
        $this->prefix = $prefix;
        $this->metaName = $this->prefix . $this->id;

        add_action( 'add_meta_boxes', array( $this, 'addMetaBox' ) );
        add_action( 'save_post', array( $this, 'saveMetaBox' ) );
    }

    /**
     * Add the meta box.
     *
     * @since 1.0.0
     * @return void
     */
    public function addMetaBox() {
        foreach ( $this->screens as $screen ) {
            add_meta_box(
                    $this->id,
                    $this->title,
                    array( $this, 'metaBoxCallback' ),
                    $screen
            );
        }
    }

    /**
     * Add the meta box.
     *
     * @since 1.0.0
     * @param \WP_Post $post
     * @return void
     */
    public function metaBoxCallback( \WP_Post $post ) {
        ?>
        <table class="form-table">
            <tbody>
            <?php foreach ( $this->fields as $field ): ?>
                <tr>
                    <th scope="row">
                        <label for="<?php echo $field['name']; ?>"><?php echo $field['label']; ?></label>
                    </th>
                    <td>
                        <?php
                        $meta = get_post_meta( $post->ID, $this->prefix . $this->id, true );
                        $methodName = 'show' . strtoupper( $field['type'] ) . 'Field';
                        if ( method_exists( $this, $methodName ) ) {
                            call_user_func( array( $this, $methodName ), $field, $meta );
                        }
                        ?>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    <?php
    }

    /**
     * Save the meta box.
     *
     * @since 1.0.0
     * @param int $postId
     * @return void
     */
    public function saveMetaBox( $postId ) {
        $isAutoSave = wp_is_post_autosave( $postId );
        $isRevision = wp_is_post_revision( $postId );
        $isValidNonce = ( isset( $_POST[$this->metaName . '_nonce'] )
                && wp_verify_nonce( $_POST[$this->metaName . '_nonce'], basename( __FILE__ ) ) ) ? true : false;
        if ( $isAutoSave || $isRevision || $isValidNonce ) {
            return;
        }

        foreach ( $this->fields as $field ) {
            $metaName = $field['name'];
            $single = !isset( $field['multiple'] ) || !$field['multiple'] ? false : true;<commit_msg>use ucfirst instead of strtoupper for magic method accessor<commit_after><?php namespace MagicMetaBox;

class MagicMetaBox {

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $id = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $title = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var array
     */
    protected $screens = array();

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $prefix = '';

    /**
     * @since 1.0.0
     * @access protected
     * @var string
     */
    protected $metaName = '';

    /**
     * @since 1.0.0
     * @access private
     * @var array
     */
    private $fields = array();

    /**
     * Initialize the class and set its properties.
     *
     * @since 1.0.0
     * @param string $id
     * @param string $title
     * @param array $screens
     * @param string $prefix
     */
    public function __construct( $id, $title, $screens, $prefix ) {
        $this->id = $id;
        $this->title = $title;
        $this->screens = $screens;
        $this->prefix = $prefix;
        $this->metaName = $this->prefix . $this->id;

        add_action( 'add_meta_boxes', array( $this, 'addMetaBox' ) );
        add_action( 'save_post', array( $this, 'saveMetaBox' ) );
    }

    /**
     * Add the meta box.
     *
     * @since 1.0.0
     * @return void
     */
    public function addMetaBox() {
        foreach ( $this->screens as $screen ) {
            add_meta_box(
                    $this->id,
                    $this->title,
                    array( $this, 'metaBoxCallback' ),
                    $screen
            );
        }
    }

    /**
     * Add the meta box.
     *
     * @since 1.0.0
     * @param \WP_Post $post
     * @return void
     */
    public function metaBoxCallback( \WP_Post $post ) {
        ?>
        <table class="form-table">
            <tbody>
            <?php foreach ( $this->fields as $field ): ?>
                <tr>
                    <th scope="row">
                        <label for="<?php echo $field['name']; ?>"><?php echo $field['label']; ?></label>
                    </th>
                    <td>
                        <?php
                        $meta = get_post_meta( $post->ID, $this->prefix . $this->id, true );
                        $methodName = 'show' . ucfirst( $field['type'] ) . 'Field';
                        if ( method_exists( $this, $methodName ) ) {
                            call_user_func( array( $this, $methodName ), $field, $meta );
                        }
                        ?>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    <?php
    }

    /**
     * Save the meta box.
     *
     * @since 1.0.0
     * @param int $postId
     * @return void
     */
    public function saveMetaBox( $postId ) {
        $isAutoSave = wp_is_post_autosave( $postId );
        $isRevision = wp_is_post_revision( $postId );
        $isValidNonce = ( isset( $_POST[$this->metaName . '_nonce'] )
                && wp_verify_nonce( $_POST[$this->metaName . '_nonce'], basename( __FILE__ ) ) ) ? true : false;
        if ( $isAutoSave || $isRevision || $isValidNonce ) {
            return;
        }

        foreach ( $this->fields as $field ) {
            $metaName = $field['name'];
            $single = !isset( $field['multiple'] ) || !$field['multiple'] ? false : true;
{'fraction_non_alphanumeric': 0.15124378109452735, 'fraction_numerical': 0.008528784648187633, 'mean_word_length': 1.382661699966136, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 73, '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': '6625756', 'n_tokens_mistral': 2186, 'n_tokens_neox': 2112, 'n_words': 489}