<commit_before><?php
/**
 * DateEnablement.php
 *
 * @copyright 2016 <NAME>, III
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 */

namespace texdc\range;

use DateTime;

/**
 * A date-based enablement.
 *
 * @author <NAME>, III
 */
final class DateEnablement implements EnablementInterface
{
    /**
     * @var DateRangeInterface
     */
    private $dateRange;

    /**
     * @param DateRangeInterface $aDateRange
     */
    public function __construct(DateRangeInterface $aDateRange)
    {
        $this->dateRange = $aDateRange;
    }

    /**
     * @param  DateTime|null $onDate optional, will default to 'now'
     * @return bool
     */
    public function isEnabled(DateTime $onDate = null) : bool
    {
        $onDate = $onDate ?: new DateTime;
        return $this->dateRange->includes($onDate);
    }
}<commit_msg>Use DateTimeInterface and null coalescing<commit_after><?php
/**
 * DateEnablement.php
 *
 * @copyright 2016 <NAME>, III
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 */

namespace texdc\range;

use DateTimeInterface;

/**
 * A date-based enablement.
 *
 * @author <NAME>, III
 */
final class DateEnablement implements EnablementInterface
{
    /**
     * @var DateRangeInterface
     */
    private $dateRange;

    /**
     * @param DateRangeInterface $aDateRange
     */
    public function __construct(DateRangeInterface $aDateRange)
    {
        $this->dateRange = $aDateRange;
    }

    /**
     * @param  DateTimeInterface|null $onDate optional, will default to 'now'
     * @return bool
     */
    public function isEnabled(DateTimeInterface $onDate = null) : bool
    {
        return $this->dateRange->includes($onDate ?? new DateTime);
    }
}
{'fraction_non_alphanumeric': 0.12542759407069556, 'fraction_numerical': 0.004561003420752566, 'mean_word_length': 2.8152173913043477, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4589028', 'n_tokens_mistral': 534, 'n_tokens_neox': 521, 'n_words': 122}