<commit_before><?php

namespace AuditStash\Persister;

use AuditStash\Event\BaseEvent;
use AuditStash\EventInterface;
use Cake\Utility\Hash;

trait ExtractionTrait
{
    /**
     * Extracts the basic fields from the audit event object.
     *
     * @param \AuditStash\EventInterface $event The event object from which to extract the fields.
     * @param bool $serialize Whether to serialize fields that are expected to hold array data.
     * @return array
     */
    protected function extractBasicFields(EventInterface $event, $serialize = true)
    {
        $fields = [
            'transaction' => $event->getTransactionId(),
            'type' => $event->getEventType(),
            'source' => $event->getSourceName(),
            'parent_source' => null,
            'original' => null,
            'changed' => null,
            'created' => new \DateTime($event->getTimestamp())
        ];
<commit_msg>add support for string datetime insert to database (#48)<commit_after><?php

namespace AuditStash\Persister;

use AuditStash\Event\BaseEvent;
use AuditStash\EventInterface;
use Cake\Database\Type;
use Cake\Database\Type\DateTimeType;
use Cake\Utility\Hash;

trait ExtractionTrait
{
    /**
     * Extracts the basic fields from the audit event object.
     *
     * @param \AuditStash\EventInterface $event The event object from which to extract the fields.
     * @param bool $serialize Whether to serialize fields that are expected to hold array data.
     * @return array
     */
    protected function extractBasicFields(EventInterface $event, $serialize = true)
    {
        $fields = [
            'transaction' => $event->getTransactionId(),
            'type' => $event->getEventType(),
            'source' => $event->getSourceName(),
            'parent_source' => null,
            'original' => null,
            'changed' => null,
            'created' => new \DateTime($event->getTimestamp())
        ];

        if (Type::getMap('datetime') !== DateTimeType::class) {
            $fields['created'] = (new \DateTime($event->getTimestamp()))->format('Y-m-d H:i:s');
        }

{'fraction_non_alphanumeric': 0.12440645773979107, 'fraction_numerical': 0.000949667616334283, 'mean_word_length': 2.70298769771529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '7370826', 'n_tokens_mistral': 586, 'n_tokens_neox': 581, 'n_words': 159}