<commit_before><?php

/*
 * This file is part of Symplify
 * Copyright (c) 2016 <NAME> (http://tomasvotruba.cz).
 */

namespace Symplify\PHP7_CodeSniffer\Sniff\Naming;

use Nette\Utils\Strings;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\InvalidSniffClassException;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\InvalidSniffCodeException;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\SniffClassCouldNotBeFoundException;

final class SniffNaming
{
    public static function guessClassByCode(string $sniffCode) : string
    {
        self::ensureSniffCodeIsValid($sniffCode);

        $parts = explode('.', $sniffCode);

        $firstGuess = $parts[0].'CodingStandard\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff';
        if (class_exists($firstGuess)) {
            return $firstGuess;
        }

        $secondGuess = $parts[0].'\\CodingStandard\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff';
        if (class_exists($secondGuess)) {
            return $secondGuess;
        }

        $thirdGuess = 'PHP_CodeSniffer\\Standards\\'.$parts[0]
            .'\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff';

        if (class_exists($thirdGuess)) {
            return $thirdGuess;
        }

        self::reportClassCouldNotBeFound($sniffCode, [$firstGuess, $secondGuess, $thirdGuess]);
    }

    public static function guessCodeByClass(string $sniffClass) : string
    {
        self::ensureClassNameIsValid($sniffClass);

        $parts = explode('\\', $sniffClass);

        $standardName = $parts[count($parts)-4];
        if (Strings::endsWith($standardName, 'CodingStandard')) {<commit_msg>SniffNaming: improve<commit_after><?php

/*
 * This file is part of Symplify
 * Copyright (c) 2016 <NAME> (http://tomasvotruba.cz).
 */

namespace Symplify\PHP7_CodeSniffer\Sniff\Naming;

use Nette\Utils\Strings;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\InvalidSniffClassException;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\InvalidSniffCodeException;
use Symplify\PHP7_CodeSniffer\Exception\Sniff\Naming\SniffClassCouldNotBeFoundException;

final class SniffNaming
{
    public static function guessClassByCode(string $sniffCode) : string
    {
        self::ensureSniffCodeIsValid($sniffCode);

        $parts = explode('.', $sniffCode);

        $possibleClasses = [
            $parts[0].'CodingStandard\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff',
            $parts[0].'\\CodingStandard\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff',
            'PHP_CodeSniffer\\Standards\\'.$parts[0].'\\Sniffs\\'.$parts[1].'\\'.$parts[2].'Sniff',
        ];

        foreach ($possibleClasses as $possibleClass) {
            if (class_exists($possibleClass)) {
                return $possibleClass;
            }
        }

        self::reportClassCouldNotBeFound($sniffCode, $possibleClasses);
    }

    public static function guessCodeByClass(string $sniffClass) : string
    {
        self::ensureClassNameIsValid($sniffClass);

        $parts = explode('\\', $sniffClass);

        $standardName = $parts[count($parts)-4];
        if (Strings::endsWith($standardName, 'CodingStandard')) {
{'fraction_non_alphanumeric': 0.15419065898912349, 'fraction_numerical': 0.011516314779270634, 'mean_word_length': 3.2777017783857727, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5087088', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1004, 'n_words': 138}