<commit_before><?php

namespace ContentTranslator\Translate;

class Meta extends \ContentTranslator\Entity\Translate
{

    private $metaType;
    private $allowedTypes = array('post','user','comment');
    private $metaConfiguration;

    /**
     * Constructor
     * @param  string $metaType The metadata type that should be handled. Valid: post, user.
     * @return void
     */
    public function __construct($metaType = 'post')
    {
        parent::__construct();

        if (in_array($metaType, $this->allowedTypes)) {
            $this->metaType = $metaType;

            if ($metaType == 'user') {
                $this->metaConfiguration = $this->configuration->usermeta;
            } else {
                $this->metaConfiguration = $this->configuration->meta;
            }
        } else {
            wp_die("An incorrent meta-type was provieded to meta translation.", 'wp-content-translator');
        }

        if (
            ($this->configuration->meta->translate && $metaType == 'post') ||
            ($this->configuration->usermeta->translate && $metaType == 'user') ||
            ($this->configuration->comment->translate && $metaType == 'comment')
        ) {
            add_filter('get_'. $this->metaType .'_metadata', array($this, 'get'), 1, 4);
            add_filter('update_'. $this->metaType .'_metadata', array($this, 'save'), 1, 4);
            add_filter('add_'. $this->metaType .'_metadata', array($this, 'save'), 1, 4);
        }
    }

    /**<commit_msg>Do not die, throw an exception.<commit_after><?php

namespace ContentTranslator\Translate;

class Meta extends \ContentTranslator\Entity\Translate
{

    private $metaType;
    private $allowedTypes = array('post','user','comment');
    private $metaConfiguration;

    /**
     * Constructor
     * @param  string $metaType The metadata type that should be handled. Valid: post, user.
     * @return void
     */
    public function __construct($metaType = 'post')
    {
        parent::__construct();

        if (in_array($metaType, $this->allowedTypes)) {
            $this->metaType = $metaType;

            if ($metaType == 'user') {
                $this->metaConfiguration = $this->configuration->usermeta;
            } else {
                $this->metaConfiguration = $this->configuration->meta;
            }
        } else {
            throw new \Exception("An incorrent meta-type was provided to meta translation.", 1);
        }

        if (
            ($this->configuration->meta->translate && $metaType == 'post') ||
            ($this->configuration->usermeta->translate && $metaType == 'user') ||
            ($this->configuration->comment->translate && $metaType == 'comment')
        ) {
            add_filter('get_'. $this->metaType .'_metadata', array($this, 'get'), 1, 4);
            add_filter('update_'. $this->metaType .'_metadata', array($this, 'save'), 1, 4);
            add_filter('add_'. $this->metaType .'_metadata', array($this, 'save'), 1, 4);
        }
    }

    /**
{'fraction_non_alphanumeric': 0.159189099368561, 'fraction_numerical': 0.004320372216683284, 'mean_word_length': 2.3668903803131993, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '4600194', 'n_tokens_mistral': 847, 'n_tokens_neox': 819, 'n_words': 185}