<commit_before><?php

namespace Estey\EvernoteOCR;

/**
 * Text
 *
 * A simple class for managing the text string returned from the Evernote API.
 * Includes the confidence score.
 */
class Text
{
    /**
     * Text.
     * @var string
     */
    public $text;

    /**
     * Confidence Score. Between 0 and 100.
     * @var integer
     */
    public $confidence;

    /**
     * New Text Element.
     * 
     * @param string $text
     * @param integer $confidence
     * @return void
     */
    public function __construct($text, $confidence)
    {
        $this->text = $text;
        $this->confidence = $confidence;
    }

    /**
     * Text Length.
     * 
     * @return integer|boolean<commit_msg>Add a little validation to Text class.<commit_after><?php

namespace Estey\EvernoteOCR;

use InvalidArgumentException;

/**
 * Text
 *
 * A simple class for managing the text string returned from the Evernote API.
 * Includes the confidence score.
 */
class Text
{
    /**
     * Text.
     * @var string
     */
    public $text;

    /**
     * Confidence Score. Between 0 and 100.
     * @var integer
     */
    public $confidence;

    /**
     * New Text Element.
     * 
     * @param string $text
     * @param integer $confidence
     * @return void
     */
    public function __construct($text, $confidence)
    {
        $this->setText($text);
        $this->setConfidence($confidence);
    }

    /**
     * Set text.
     * 
     * @param string $text
     * @return $this
     */
    public function setText($text)
    {
        $this->text = $text;
        return $this;
    }

    /**
     * Set confidence score.
     * 
     * @param integer $confidence
     * @return $this
     */
    public function setConfidence($confidence)
    {
        if (!is_int($confidence) or $confidence < 0 or $confidence > 100) {
            throw new InvalidArgumentException(
                'Confidence score must be an integer between 0 and 100.'
            );
        }
        $this->confidence = $confidence;
        return $this;
    }

    /**
     * Text Length.
     * 
     * @return integer|boolean
{'fraction_non_alphanumeric': 0.11670588235294117, 'fraction_numerical': 0.0075294117647058826, 'mean_word_length': 1.8010540184453228, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, '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': '7267174', 'n_tokens_mistral': 656, 'n_tokens_neox': 606, 'n_words': 177}