<commit_before><?php

namespace iiifx\LazyInit;

use Closure;
use ErrorException;

/**
 * Class LazyInitHelper.
 *
 * @author  <NAME> <<EMAIL>>
 *
 * @link    https://github.com/iiifx-production/lazy-init
 */
class LazyInitHelper
{
    use LazyInitStaticTrait;

    /**
     * @param Closure     $closure
     * @param string|null $key
     * @param mixed[]     $params
     *
     * @return mixed
     *
     * @throws ErrorException
     */
    public static function lazyInit ( Closure $closure, $key = null, array $params = [ ] )
    {
        if ( $key === null ) {
            $key = static::createBacktraceKey();
        }

        return static::lazyInitStatic( $closure, $key, $params );
    }

    /**
     * @param int $backtraceDepth
     *
     * @return string
     *
     * @throws ErrorException
     */
    public static function createBacktraceKey ( $backtraceDepth = 2 )
    {
        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, $backtraceDepth );
        $backtraceKey = $backtraceDepth - 1;
        if ( isset( $backtrace[ $backtraceKey ][ 'file' ], $backtrace[ $backtraceKey ][ 'line' ] ) ) {
            $parts = [ ];
            $parts[] = $backtrace[ $backtraceKey ][ 'file' ];
            $parts[] = $backtrace[ $backtraceKey ][ 'line' ];

            return md5( implode( '#', $parts ) );
        }
        throw new ErrorException( 'Unable to create BacktraceKey.' );
    }
}<commit_msg>Оптимизировал методы<commit_after><?php

namespace iiifx\LazyInit;

use Closure;
use ErrorException;

/**
 * Class LazyInitHelper.
 *
 * @author <NAME> <<EMAIL>>
 *
 * @link   https://github.com/iiifx-production/lazy-init
 */
class LazyInitHelper
{
    use LazyInitStaticTrait;

    /**
     *
     */
    const PART_SEPARATOR = '#';

    /**
     * @param Closure     $closure
     * @param string|null $key
     * @param mixed[]     $params
     *
     * @return mixed
     *
     * @throws ErrorException
     */
    public static function lazyInit ( Closure $closure, $key = null, array $params = [ ] )
    {
        if ( $key === null ) {
            $key = static::createBacktraceKey();
        }

        return static::lazyInitStatic( $closure, $key, $params );
    }

    /**
     * @param int $backtraceDepth
     *
     * @return string
     *
     * @throws ErrorException
     */
    public static function createBacktraceKey ( $backtraceDepth = 3 )
    {
        if ( $backtraceData = static::createBacktraceData( $backtraceDepth ) ) {
            return implode( static::PART_SEPARATOR, $backtraceData );
        }
        throw new ErrorException( 'Unable to create BacktraceKey.' );
    }

    /**
     * @param int $backtraceDepth
     *
     * @return array
     *
     * @throws ErrorException
     */
    public static function createBacktraceData ( $backtraceDepth = 0 )
    {
        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, $backtraceDepth );
        $backtraceKey = $backtraceDepth - 1;
        if ( isset( $backtrace[ $backtraceKey ][ 'file' ], $backtrace[ $backtraceKey ][ 'line' ] ) ) {
            $parts = [ ];
            $parts[] = $backtrace[ $backtraceKey ][ 'file' ];
            $parts[] = $backtrace[ $backtraceKey ][ 'line' ];

            return $parts;
        }
        throw new ErrorException( 'Unable to create BacktraceData.' );
    }
}
{'fraction_non_alphanumeric': 0.13547611895464104, 'fraction_numerical': 0.0018023430459597476, 'mean_word_length': 2.205004812319538, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1520588', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1037, 'n_words': 227}