<commit_before><?php

namespace Depot\Testing\Fixtures\Banking\Common;

use DateTimeImmutable;
use Depot\AggregateRoot\Support\ChangeReading\AggregateRootChangeReading;

class BankingEventEnvelope implements AggregateRootChangeReading
{
    /**
     * @var object
     */
    public $event;

    /**
     * @var null
     */
    public $metadata;

    /**
     * @var string
     */
    public $eventId;

    /**
     * @var DateTimeImmutable
     */
    public $when;

    /**
     * @var int
     */
    public $version;

    private function __construct($eventId, $event, $when = null, $metadata = null, $version = null)
    {
        $this->eventId = $eventId;
        $this->event = $event;
        $this->when = (is_null($when)) ? new DateTimeImmutable('now') : $when;
        $this->metadata = $metadata;
        $this->version = null;
    }

    public static function create($eventId, $event, $when = null, $metadata = null, $version = null)
    {
        return new self($eventId, $event, $when, $metadata, $version);
    }

    public static function instantiateAggregateChangeFromEventAndMetadata(
        $eventId,
        $event,
        $when = null,
        $metadata = null,
        $version = null
    )
    {
        return new self($eventId, $event, $when, $metadata, $version);
    }

    /**
     * @return object
     */
    public function getAggregateEvent()
    {
        return $this->event;
    }

    /**
     * @return object
     */
    public function getAggregateMetadata()
    {
        return $this->metadata;
    }

    /**
     * @return object
     */
    public function getCanReadAggregateEventId()
    {
        return true;
    }

    /**
     * @return object
     */
    public function getAggregateEventId()
    {
        return $this->eventId;
    }

    /**
     * @return bool
     */
    public function getCanReadAggregateEventVersion()
    {
        return true;
    }

    /**
     * @return object
     */
    public function getAggregateEventVersion()
    {
        return $this->version;
    }

    /**
     * @return DateTimeImmutable
     */
    public function getAggregateEventWhen()
    {
        return $this->when;
    }
}<commit_msg>Provide a way to update when (for testing only)<commit_after><?php

namespace Depot\Testing\Fixtures\Banking\Common;

use DateTimeImmutable;
use Depot\AggregateRoot\Support\ChangeReading\AggregateRootChangeReading;

class BankingEventEnvelope implements AggregateRootChangeReading
{
    /**
     * @var object
     */
    public $event;

    /**
     * @var null
     */
    public $metadata;

    /**
     * @var string
     */
    public $eventId;

    /**
     * @var DateTimeImmutable
     */
    public $when;

    /**
     * @var int
     */
    public $version;

    private function __construct($eventId, $event, $when = null, $metadata = null, $version = null)
    {
        $this->eventId = $eventId;
        $this->event = $event;
        $this->when = (is_null($when)) ? new DateTimeImmutable('now') : $when;
        $this->metadata = $metadata;
        $this->version = null;
    }

    public static function create($eventId, $event, $when = null, $metadata = null, $version = null)
    {
        return new self($eventId, $event, $when, $metadata, $version);
    }

    public static function instantiateAggregateChangeFromEventAndMetadata(
        $eventId,
        $event,
        $when = null,
        $metadata = null,
        $version = null
    )
    {
        return new self($eventId, $event, $when, $metadata, $version);
    }

    /**
     * @return object
     */
    public function getAggregateEvent()
    {
        return $this->event;
    }

    /**
     * @return object
     */
    public function getAggregateMetadata()
    {
        return $this->metadata;
    }

    /**
     * @return object
     */
    public function getCanReadAggregateEventId()
    {
        return true;
    }

    /**
     * @return object
     */
    public function getAggregateEventId()
    {
        return $this->eventId;
    }

    /**
     * @return bool
     */
    public function getCanReadAggregateEventVersion()
    {
        return true;
    }

    /**
     * @return object
     */
    public function getAggregateEventVersion()
    {
        return $this->version;
    }

    /**
     * @return DateTimeImmutable
     */
    public function getAggregateEventWhen()
    {
        return $this->when;
    }

    public function withWhen(\DateTimeImmutable $when)
    {
        $instance = clone($this);
        $instance->when = $when;

        return $instance;
    }
}
{'fraction_non_alphanumeric': 0.12423714036617263, 'fraction_numerical': 0.0, 'mean_word_length': 1.9856864020819778, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '5314859', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1369, 'n_words': 298}