<commit_before><?php
namespace Concrete\Core\Entity\Attribute\Value\Value;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="NumberAttributeValues")
 */
class NumberValue extends Value
{
    /**
     * @ORM\Column(type="decimal", precision=14, scale=4, nullable=true)
     */
    protected $value = '';

    /**
     * @return mixed
     */
    public function getValue()
    {
        $number = \Core::make('helper/number');
        return (string) $number->flexround($this->getUnroundedValue());
    }

    public function getUnroundedValue()
    {
        return $this->value;
    }

    /**
     * @param mixed $value
     */
    public function setValue($value)
    {
        $this->value = $value;
    }

    public function __toString()
    {
        return (string) $this->getValue();
    }
}<commit_msg>Better handling of null values in NumberValue (#4325)<commit_after><?php
namespace Concrete\Core\Entity\Attribute\Value\Value;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="NumberAttributeValues")
 */
class NumberValue extends Value
{
    /**
     * @ORM\Column(type="decimal", precision=14, scale=4, nullable=true)
     */
    protected $value = null;

    /**
     * @return float|null
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * @param float|null $value
     */
    public function setValue($value)
    {
        if ($value === '' || $value === null) {
            $this->value = null;
        } else {
            $this->value = (float) $value;
        }
    }

    /**
     * {@inheritdoc}
     *
     * @see Value::__toString()
     */
    public function __toString()
    {
        return (string) $this->value;
    }
}
{'fraction_non_alphanumeric': 0.15729047072330654, 'fraction_numerical': 0.0057405281285878304, 'mean_word_length': 2.227777777777778, 'pattern_counts': {'":': 0, '<': 5, '<?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': '977562', 'n_tokens_mistral': 552, 'n_tokens_neox': 536, 'n_words': 107}