<commit_before><?php

/**
 * This file is part of the Cubiche package.
 *
 * Copyright (c) Cubiche
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cubiche\Infrastructure\Identity\Doctrine\ODM\MongoDB\Types;

use Cubiche\Infrastructure\Model\Doctrine\ODM\MongoDB\Types\NativeValueObjectType;

/**
 * Abstract Id Type Class.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class IdType extends NativeValueObjectType
{
    /**
     * {@inheritdoc}
     */
    public function convertToDatabaseValue($value)
    {
        $class = $this->targetClass();
        if (!$value instanceof $class) {
            return $value;
        }

        return parent::convertToDatabaseValue($value);
    }

    /**
     * {@inheritdoc}
     */
    public function closureToPHP()
    {
        $class = $this->targetClass();

        return '
        $return = $value !== null && $value instanceof \\'.$class.' ? \\'.$class.'::fromNative($value) : $value;
        ';
    }
}<commit_msg>removed invalid closureToPHP method<commit_after><?php

/**
 * This file is part of the Cubiche package.
 *
 * Copyright (c) Cubiche
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cubiche\Infrastructure\Identity\Doctrine\ODM\MongoDB\Types;

use Cubiche\Infrastructure\Model\Doctrine\ODM\MongoDB\Types\NativeValueObjectType;

/**
 * Abstract Id Type Class.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class IdType extends NativeValueObjectType
{
    /**
     * {@inheritdoc}
     */
    public function convertToDatabaseValue($value)
    {
        $class = $this->targetClass();
        if (!$value instanceof $class) {
            return $value;
        }

        return parent::convertToDatabaseValue($value);
    }
}
{'fraction_non_alphanumeric': 0.12673056443024494, 'fraction_numerical': 0.0, 'mean_word_length': 2.858316221765914, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, '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': '5045946', 'n_tokens_mistral': 538, 'n_tokens_neox': 538, 'n_words': 140}