<commit_before><?php
/**
 * This file is part of the Composite Utils package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the
 * LICENSE.md file that was distributed with this source code.
 *
 * @package spaark/composite-utils
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

namespace Spaark\CompositeUtils\Model;

use Spaark\CompositeUtils\Traits\AllReadableTrait;

/**
 * Models a classname which has both a namespace and a classname
 */
class ClassName
{
    use AllReadableTrait;

    /**
     * @var string
     */
    protected $namespace = '';

    /**
     * @var string
     */
    protected $classname;

    /**
     * Constructs the ClassName by taking a fully qualified classname
     * and splitting it into its namespace and classname sections
     *
     * @param string $classname
     */
    public function __construct(string $classname)
    {
        preg_match('/(.+)\\\\([a-z_A-Z0-9]+)/', $classname, $matches);

        if (!$matches)
        {
            $this->classname = $classname;
        }
        else
        {
            $this->classname = $matches[2];
            $this->namespace = $matches[1];
        }
    }

    /**
     * Returns the fully qualified classname
     *
     * @return string
     */
    public function __toString()
    {
        return
              ($this->namespace ? $this->namespace . '\\' : '')
            . $this->classname;
    }
}
<commit_msg>Add ClassName::equals()<commit_after><?php
/**
 * This file is part of the Composite Utils package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the
 * LICENSE.md file that was distributed with this source code.
 *
 * @package spaark/composite-utils
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

namespace Spaark\CompositeUtils\Model;

use Spaark\CompositeUtils\Traits\AllReadableTrait;

/**
 * Models a classname which has both a namespace and a classname
 */
class ClassName
{
    use AllReadableTrait;

    /**
     * @var string
     */
    protected $namespace = '';

    /**
     * @var string
     */
    protected $classname;

    /**
     * Constructs the ClassName by taking a fully qualified classname
     * and splitting it into its namespace and classname sections
     *
     * @param string $classname
     */
    public function __construct(string $classname)
    {
        preg_match('/(.+)\\\\([a-z_A-Z0-9]+)/', $classname, $matches);

        if (!$matches)
        {
            $this->classname = $classname;
        }
        else
        {
            $this->classname = $matches[2];
            $this->namespace = $matches[1];
        }
    }

    /**
     * Returns the fully qualified classname
     *
     * @return string
     */
    public function __toString()
    {
        return
              ($this->namespace ? $this->namespace . '\\' : '')
            . $this->classname;
    }

    /**
     * Checks if this Classname is equal to another
     *
     * @param ClassName $object
     * @return boolean
     */
    public function equals(self $object) : bool
    {
        return
            $object->classname === $this->classname &&
            $object->namespace === $this->namespace;
    }
}

{'fraction_non_alphanumeric': 0.12932098765432098, 'fraction_numerical': 0.0024691358024691358, 'mean_word_length': 2.0318054256314313, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, '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': '7522487', 'n_tokens_mistral': 961, 'n_tokens_neox': 945, 'n_words': 258}