<commit_before><?php

namespace MusicBrainz\Value;

/**
 * A date
 *
 * @see https://musicbrainz.org/doc/IPI
 */
class Date
{
    /**
     * The format for constructing a date
     * YYYY-MM-DD (leading zeros for months and days)
     *
     * @var string
     */
    private const FORMAT = 'Y-m-d';

    /**
     * Date and time
     *
     * @var null|\DateTime
     */
    private $dateTime;

    /**
     * Constructs a date
     *
     * @param string $date A date formatted as defined on top
     */
    public function __construct(string $date)
    {
        $dateTime = \DateTime::createFromFormat(self::FORMAT, $date);

        $this->dateTime = ($dateTime && $dateTime->format(self::FORMAT) === $date)
            ? $dateTime
            : null;
    }

    /**
     * Returns the date in the originally given format.
     *
     * @return null|string
     */
    public function __toString(): string
    {
        return ($this->dateTime)
            ? $this->dateTime->format(self::FORMAT)
            : null;
    }
}<commit_msg>Fixed Date::__toString(): must always return a string, of course.<commit_after><?php

namespace MusicBrainz\Value;

/**
 * A date
 *
 * @see https://musicbrainz.org/doc/IPI
 */
class Date
{
    /**
     * The format for constructing a date
     * YYYY-MM-DD (leading zeros for months and days)
     *
     * @var string
     */
    private const FORMAT = 'Y-m-d';

    /**
     * Date and time
     *
     * @var null|\DateTime
     */
    private $dateTime;

    /**
     * Constructs a date
     *
     * @param string $date A date formatted as defined on top
     */
    public function __construct(string $date)
    {
        $dateTime = \DateTime::createFromFormat(self::FORMAT, $date);

        $this->dateTime = ($dateTime && $dateTime->format(self::FORMAT) === $date)
            ? $dateTime
            : null;
    }

    /**
     * Returns the date in the originally given format.
     *
     * @return string
     */
    public function __toString(): string
    {
        return ($this->dateTime)
            ? $this->dateTime->format(self::FORMAT)
            : '';
    }
}
{'fraction_non_alphanumeric': 0.13647058823529412, 'fraction_numerical': 0.0, 'mean_word_length': 1.896457765667575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '4015681', 'n_tokens_mistral': 661, 'n_tokens_neox': 643, 'n_words': 165}