<commit_before><?php
/**
 * Part of composer package: axelitus/base
 *
 * @package     axelitus\Base
 * @version     0.2
 * @author      <NAME> (<EMAIL>)
 * @license     MIT License
 * @copyright   2013 - Axel Pardemann
 * @link        http://axelitus.mx/projects/axelitus/base
 */

namespace axelitus\Base;

use axelitus\Base\Primitives\String\PrimitiveString;

/**
 * Class String
 *
 * Defines a String.
 *
 * @package axelitus\Base
 */
class String extends PrimitiveString
{
    /**
     * Determines if two given values are equal.
     *
     * The given values $a and $b must be of type string. For the sake of this implementation
     * there is no distinction between the == equal operator and the identical === operator.
     *
     * @param int|float|PrimitiveString $a The first of the values to compare.
     * @param int|float|PrimitiveString $b The second of the values to compare.
     *
     * @return bool Returns true if both values are numeric and are equal, false otherwise.<commit_msg>Added the str() function to evaluate the given value (string or PrimitiveString) and return the native string value.<commit_after><?php
/**
 * Part of composer package: axelitus/base
 *
 * @package     axelitus\Base
 * @version     0.2
 * @author      <NAME> (<EMAIL>)
 * @license     MIT License
 * @copyright   2013 - Axel Pardemann
 * @link        http://axelitus.mx/projects/axelitus/base
 */

namespace axelitus\Base;

use axelitus\Base\Primitives\String\PrimitiveString;

/**
 * Class String
 *
 * Defines a String.
 *
 * @package axelitus\Base
 */
class String extends PrimitiveString
{
    /**
     * Gets the native string of a given value. If the given value is of type PrimitiveString,
     * the object's value is returned, if it's a string, the string is returned unaltered. If
     * it's something else, an exception is thrown.
     *
     * @param string|PrimitiveString $value The value to get the native string value from.
     *
     * @throws \InvalidArgumentException
     * @return string The native string value.
     */
    public static function str($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException("The \$value must be a string or instances derived from PrimitiveString.");
        }

        return (is_object($value) and ($value instanceof PrimitiveString)) ? $value->value() : $value;
    }

    /**
     * Determines if two given values are equal.
     *
     * The given values $a and $b must be of type string. For the sake of this implementation
     * there is no distinction between the == equal operator and the identical === operator.
     *
     * @param int|float|PrimitiveString $a The first of the values to compare.
     * @param int|float|PrimitiveString $b The second of the values to compare.
     *
     * @return bool Returns true if both values are numeric and are equal, false otherwise.
{'fraction_non_alphanumeric': 0.09446366782006921, 'fraction_numerical': 0.004152249134948097, 'mean_word_length': 2.8701472556894245, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, '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': '7122560', 'n_tokens_mistral': 827, 'n_tokens_neox': 791, 'n_words': 315}