<commit_before><?php
/**
 * Pkvs package
 *
 * @package Pkvs
 * @author  <NAME> <<EMAIL>>
 */

namespace GpsLab\Component\Interval\Persistence\Doctrine\DBAL\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TextType;
use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException;
use GpsLab\Component\Interval\IntervalInterface;

abstract class BaseType extends TextType
{
    /**
     * @param IntervalInterface|null $value
     * @param AbstractPlatform $platform
     *
     * @return null|string
     */
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        $class = $this->getIntervalClass();

        return $value instanceof $class ? (string)$value : null;
    }

    /**
     * @throws ConversionException
     *
     * @param mixed $value
     * @param AbstractPlatform $platform
     *
     * @return null|IntervalInterface
     */
    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }

        try {
            return call_user_func([$this->getIntervalClass(), 'fromString'], $value);
        } catch (InvalidIntervalFormatException $e) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }
    }

    /**
     * @return string
     */
    public function getName()
    {
        return basename($this->getIntervalClass());
    }

    /**
     * @return string
     */
    abstract protected function getIntervalClass();
}<commit_msg>corect get Doctrine type name from class<commit_after><?php
/**
 * Pkvs package
 *
 * @package Pkvs
 * @author  <NAME> <<EMAIL>>
 */

namespace GpsLab\Component\Interval\Persistence\Doctrine\DBAL\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TextType;
use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException;
use GpsLab\Component\Interval\IntervalInterface;

abstract class BaseType extends TextType
{
    /**
     * @param IntervalInterface|null $value
     * @param AbstractPlatform $platform
     *
     * @return null|string
     */
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        $class = $this->getIntervalClass();

        return $value instanceof $class ? (string)$value : null;
    }

    /**
     * @throws ConversionException
     *
     * @param mixed $value
     * @param AbstractPlatform $platform
     *
     * @return null|IntervalInterface
     */
    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }

        try {
            return call_user_func([$this->getIntervalClass(), 'fromString'], $value);
        } catch (InvalidIntervalFormatException $e) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }
    }

    /**
     * @return string
     */
    public function getName()
    {
        $names = explode('\\', $this->getIntervalClass());

        return array_pop($names);
    }

    /**
     * @return string
     */
    abstract protected function getIntervalClass();
}
{'fraction_non_alphanumeric': 0.11838482716427041, 'fraction_numerical': 0.0, 'mean_word_length': 2.802325581395349, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '4222723', 'n_tokens_mistral': 917, 'n_tokens_neox': 898, 'n_words': 189}