<commit_before><?php

declare(strict_types=1);

namespace Knp\DoctrineBehaviors\Model\Loggable;

use DateTime;

trait LoggableTrait
{
    public function getUpdateLogMessage(array $changeSets = []): string
    {
        $message = [];
        foreach ($changeSets as $property => $changeSet) {
            $itemCount = count($changeSet);

            for ($i = 0, $s = $itemCount; $i < $s; $i++) {
                $item = $changeSet[$i];

                if ($item instanceof DateTime) {
                    $changeSet[$i] = $item->format('Y-m-d H:i:s.u');
                }
            }

            if ($changeSet[0] === $changeSet[1]) {
                continue;
            }

            $message[] = $this->createChangeSetMessage($property, $changeSet);
        }

        return implode("\n", $message);
    }

    public function getCreateLogMessage(): string
    {
        return sprintf('%s #%d created', self::class, $this->getId());
    }

    public function getRemoveLogMessage(): string
    {
        return sprintf('%s #%d removed', self::class, $this->getId());
    }

    private function createChangeSetMessage(string $property, array $changeSet): string
    {
        return sprintf(
            '%s #%d : property "%s" changed from "%s" to "%s"',
            self::class,
            $this->getId(),
            $property,<commit_msg>Update LoggableTrait.php (#594)<commit_after><?php

declare(strict_types=1);

namespace Knp\DoctrineBehaviors\Model\Loggable;

use DateTime;

trait LoggableTrait
{
    public function getUpdateLogMessage(array $changeSets = []): string
    {
        $message = [];
        foreach ($changeSets as $property => $changeSet) {
            $itemCount = count($changeSet);

            for ($i = 0, $s = $itemCount; $i < $s; $i++) {
                $item = $changeSet[$i];

                if ($item instanceof DateTime) {
                    $changeSet[$i] = $item->format('Y-m-d H:i:s.u');
                }
            }

            if ($changeSet[0] === $changeSet[1]) {
                continue;
            }

            $message[] = $this->createChangeSetMessage($property, $changeSet);
        }

        return implode("\n", $message);
    }

    public function getCreateLogMessage(): string
    {
        return sprintf('%s #%s created', self::class, $this->getId());
    }

    public function getRemoveLogMessage(): string
    {
        return sprintf('%s #%s removed', self::class, $this->getId());
    }

    private function createChangeSetMessage(string $property, array $changeSet): string
    {
        return sprintf(
            '%s #%s : property "%s" changed from "%s" to "%s"',
            self::class,
            $this->getId(),
            $property,
{'fraction_non_alphanumeric': 0.1523809523809524, 'fraction_numerical': 0.00402930402930403, 'mean_word_length': 2.0479910714285716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '2121133', 'n_tokens_mistral': 812, 'n_tokens_neox': 795, 'n_words': 179}