<commit_before><?php

namespace Humweb\Features\Resolvers;

/**
 * ClassResolver.
 */
class ClassResolver
{
    protected $namespace = '';
    protected $suffix    = '';


    /**
     * @param string $class
     *
     * @return string
     */
    public function resolve($class)
    {
        $assembledClass = '\\'.trim($this->getNamespace(), '\\').'\\'.ucfirst($class).$this->getSuffix();

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

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

        throw new \InvalidArgumentException('Unable to resolve class: '.$class.' or '.$assembledClass);
    }


    /**
     * @param mixed $namespace
     *
     * @return ClassResolver
     */
    public function setNamespace($namespace)
    {<commit_msg>ensure class name is sludly case for class resolver<commit_after><?php

namespace Humweb\Features\Resolvers;

/**
 * ClassResolver.
 */
class ClassResolver
{
    protected $namespace = '';
    protected $suffix    = '';


    /**
     * @param string $class
     *
     * @return string
     */
    public function resolve($class)
    {
        $class = $this->formatClassName($class);

        $assembledClass = '\\'.trim($this->getNamespace(), '\\').'\\'.$class.$this->getSuffix();

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

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

        throw new \InvalidArgumentException('Unable to resolve class: '.$class.' or '.$assembledClass);
    }


    /**
     * Format class name to "studly case"
     *
     * @param string $name
     *
     * @return string
     */
    protected function formatClassName($name)
    {
        $name = ucwords(str_replace(['-', '_'], ' ', $name));

        return str_replace(' ', '', $name);
    }


    /**
     * @param mixed $namespace
     *
     * @return ClassResolver
     */
    public function setNamespace($namespace)
    {
{'fraction_non_alphanumeric': 0.15242378810594703, 'fraction_numerical': 0.0, 'mean_word_length': 2.123244929797192, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2467421', 'n_tokens_mistral': 586, 'n_tokens_neox': 556, 'n_words': 122}