<commit_before><?php declare(strict_types=1);

namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\Faker;

use Doctrine\Common\Persistence\Mapping\ClassMetadata;

/**
 * This is a fork of the standard Faker column type guesser with DSM specific changes
 *
 * @see \Faker\ORM\Doctrine\ColumnTypeGuesser
 */
class ColumnTypeGuesser
{
    protected $generator;

    /**
     * @param \Faker\Generator $generator
     */
    public function __construct(\Faker\Generator $generator)
    {
        $this->generator = $generator;
    }

    /**
     * @param string        $fieldName
     * @param ClassMetadata $class
     *
     * @return \Closure|null
     */
    public function guessFormat(string $fieldName, ClassMetadata $class): ?callable
    {
        $generator = $this->generator;
        $type      = $class->getTypeOfField($fieldName);
        switch ($type) {
            case 'boolean':
                return function () use ($generator) {
                    return $generator->boolean;
                };
            case 'decimal':
                $nbDigits = $class->fieldMappings[$fieldName]['precision'] ?? 4;
                while ($nbDigits > 4) {
                    $max = pow(10, $nbDigits);
                    if ($max > mt_getrandmax()) {
                        $nbDigits--;
                        continue;
                    }
                    break;
                }
<commit_msg>fixing stan issues<commit_after><?php declare(strict_types=1);

namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\Faker;

use Doctrine\ORM\Mapping\ClassMetadataInfo;

/**
 * This is a fork of the standard Faker column type guesser with DSM specific changes
 *
 * @see \Faker\ORM\Doctrine\ColumnTypeGuesser
 */
class ColumnTypeGuesser
{
    protected $generator;

    /**
     * @param \Faker\Generator $generator
     */
    public function __construct(\Faker\Generator $generator)
    {
        $this->generator = $generator;
    }

    /**
     * @param string            $fieldName
     * @param ClassMetadataInfo $class
     *
     * @return \Closure|null
     */
    public function guessFormat(string $fieldName, ClassMetadataInfo $class): ?callable
    {
        $generator = $this->generator;
        $type      = $class->getTypeOfField($fieldName);
        switch ($type) {
            case 'boolean':
                return function () use ($generator) {
                    return $generator->boolean;
                };
            case 'decimal':
                $nbDigits = $class->fieldMappings[$fieldName]['precision'] ?? 4;
                while ($nbDigits > 4) {
                    $max = 10 ** $nbDigits;
                    if ($max > mt_getrandmax()) {
                        $nbDigits--;
                        continue;
                    }
                    break;
                }

{'fraction_non_alphanumeric': 0.112, 'fraction_numerical': 0.0034782608695652175, 'mean_word_length': 1.752153110047847, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2275144', 'n_tokens_mistral': 787, 'n_tokens_neox': 754, 'n_words': 166}