<commit_before><?php

namespace Spatie\String;

use ArrayAccess;
use Spatie\String\Exceptions\ErrorCreatingStringException;
use Spatie\String\Exceptions\UnknownFunctionException;
use Spatie\String\Exceptions\UnsetOffsetException;
use Spatie\String\Integrations\Underscore;

/**
 * Magic methods provided by underscore are documented here.
 *
 * @see \Underscore\Methods\StringsMethods
 *
 * @method \Spatie\String\Str accord($count, $many, $one, $zero = null)
 * @method \Spatie\String\Str random($length = 16)
 * @method \Spatie\String\Str quickRandom($length = 16)
 * @method randomStrings($words, $length = 10)
 * @method bool endsWith($needles)
 * @method bool isIp()
 * @method bool isEmail()
 * @method bool isUrl()
 * @method bool startsWith()
 * @method bool find($needle, $caseSensitive = false, $absolute = false)
 * @method array slice($slice)
 * @method \Spatie\String\Str sliceFrom($slice)
 * @method \Spatie\String\Str sliceTo($slice)
 * @method \Spatie\String\Str baseClass()
 * @method \Spatie\String\Str prepend($with)
 * @method \Spatie\String\Str append($with)
 * @method \Spatie\String\Str limit($limit = 100, $end = '...')
 * @method \Spatie\String\Str remove($remove)
 * @method \Spatie\String\Str replace($replace, $with)
 * @method \Spatie\String\Str toggle($first, $second, $loose = false)
 * @method \Spatie\String\Str slugify($separator = '-')
 * @method array explode($with, $limit = null)
 * @method \Spatie\String\Str lower()
 * @method \Spatie\String\Str plural()
 * @method \Spatie\String\Str singular()
 * @method \Spatie\String\Str upper()
 * @method \Spatie\String\Str title()
 * @method \Spatie\String\Str words($words = 100, $end = '...')
 * @method \Spatie\String\Str toPascalCase()
 * @method \Spatie\String\Str toSnakeCase()
 * @method \Spatie\String\Str toCamelCase()
 */
class Str implements ArrayAccess
{
    /**
     * @var string
     */
    protected $string;

    /**
     * @param string $string
     */
    public function __construct($string = '')
    {
        if (is_array($string)) {
            throw new ErrorCreatingStringException('Can\'t create string from an array');
        }

        if (is_object($string) && !method_exists($string, '__toString')) {
            throw new ErrorCreatingStringException(
                'Can\'t create string from an object that doesn\'t implement __toString'
            );
        }

        $this->string = (string) $string;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return $this->string;
    }

    /**
     * Get the string between the given start and end.<commit_msg>Applied fixes from StyleCI<commit_after><?php

namespace Spatie\String;

use ArrayAccess;
use Spatie\String\Exceptions\ErrorCreatingStringException;
use Spatie\String\Exceptions\UnknownFunctionException;
use Spatie\String\Exceptions\UnsetOffsetException;
use Spatie\String\Integrations\Underscore;

/**
 * Magic methods provided by underscore are documented here.
 *
 * @see \Underscore\Methods\StringsMethods
 *
 * @method \Spatie\String\Str accord($count, $many, $one, $zero = null)
 * @method \Spatie\String\Str random($length = 16)
 * @method \Spatie\String\Str quickRandom($length = 16)
 * @method randomStrings($words, $length = 10)
 * @method bool endsWith($needles)
 * @method bool isIp()
 * @method bool isEmail()
 * @method bool isUrl()
 * @method bool startsWith()
 * @method bool find($needle, $caseSensitive = false, $absolute = false)
 * @method array slice($slice)
 * @method \Spatie\String\Str sliceFrom($slice)
 * @method \Spatie\String\Str sliceTo($slice)
 * @method \Spatie\String\Str baseClass()
 * @method \Spatie\String\Str prepend($with)
 * @method \Spatie\String\Str append($with)
 * @method \Spatie\String\Str limit($limit = 100, $end = '...')
 * @method \Spatie\String\Str remove($remove)
 * @method \Spatie\String\Str replace($replace, $with)
 * @method \Spatie\String\Str toggle($first, $second, $loose = false)
 * @method \Spatie\String\Str slugify($separator = '-')
 * @method array explode($with, $limit = null)
 * @method \Spatie\String\Str lower()
 * @method \Spatie\String\Str plural()
 * @method \Spatie\String\Str singular()
 * @method \Spatie\String\Str upper()
 * @method \Spatie\String\Str title()
 * @method \Spatie\String\Str words($words = 100, $end = '...')
 * @method \Spatie\String\Str toPascalCase()
 * @method \Spatie\String\Str toSnakeCase()
 * @method \Spatie\String\Str toCamelCase()
 */
class Str implements ArrayAccess
{
    /**
     * @var string
     */
    protected $string;

    /**
     * @param string $string
     */
    public function __construct($string = '')
    {
        if (is_array($string)) {
            throw new ErrorCreatingStringException('Can\'t create string from an array');
        }

        if (is_object($string) && ! method_exists($string, '__toString')) {
            throw new ErrorCreatingStringException(
                'Can\'t create string from an object that doesn\'t implement __toString'
            );
        }

        $this->string = (string) $string;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return $this->string;
    }

    /**
     * Get the string between the given start and end.
{'fraction_non_alphanumeric': 0.1482469512195122, 'fraction_numerical': 0.004573170731707317, 'mean_word_length': 3.3416046319272126, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5542641', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1641, 'n_words': 396}