<commit_before><?php

namespace LaravelPM\Mappers\DoctrineORM;

use LaravelPM\Mappers\MessageMapperInterface;
use LaravelPM\Models\Message;
use LaravelPM\Models\MessageInterface;

class MessageMapper implements MessageMapperInterface
{
    protected $objectManager;

    public function __construct($objectManager)
    {
        $this->objectManager = $objectManager;
    }

    /**
     * Find message from id
     *
     * @param string $id
     * @return MessageInterface|null
     */
    public function find($id)
    {
        return $this->objectManager->find(Message::class, $id);
    }

    /**ActivityServiceProvider.php
     * Save message
     *
     * @param MessageInterface $message
     * @return MessageInterface
     */
    public function save(MessageInterface $message)
    {
        $this->objectManager->persist($message);
        $this->objectManager->flush();

        return $message;
    }

    /**
     * Remove message
     *
     * @param MessageInterface $message
     * @return bool
     */
    public function remove(MessageInterface $message)
    {
        $this->objectManager->remove($message);
        $this->objectManager->flush();

        return true;
    }
}<commit_msg>Get user conversations<commit_after><?php

namespace LaravelPM\Mappers\DoctrineORM;

use Doctrine\Common\Persistence\ObjectManager;
use LaravelPM\Mappers\MessageMapperInterface;
use LaravelPM\Models\Conversation;
use LaravelPM\Models\ConversationInterface;
use LaravelPM\Models\Message;
use LaravelPM\Models\MessageInterface;
use LaravelPM\Models\UserInterface;

class MessageMapper implements MessageMapperInterface
{
    /** @var ObjectManager */
    protected $objectManager;

    public function __construct(ObjectManager $objectManager)
    {
        $this->objectManager = $objectManager;
    }

    /**
     * Find message from id
     *
     * @param string $id
     * @return MessageInterface|null
     */
    public function find($id)
    {
        return $this->objectManager->find(Message::class, $id);
    }

    /**
     * Save message
     *
     * @param MessageInterface $message
     * @return MessageInterface
     */
    public function save(MessageInterface $message)
    {
        $this->objectManager->persist($message);
        $this->objectManager->flush();

        return $message;
    }

    /**
     * Remove message
     *
     * @param MessageInterface $message
     * @return bool
     */
    public function remove(MessageInterface $message)
    {
        $this->objectManager->remove($message);
        $this->objectManager->flush();

        return true;
    }

    /**
     * Find user conversations
     *
     * @param UserInterface $user
     * @return ConversationInterface[]|array
     */
    public function getUserConversations(UserInterface $user)
    {
        return $this->objectManager->getRepository(Conversation::class)->findBy([
            'user' => $user,
        ]);
    }
}
{'fraction_non_alphanumeric': 0.11167858358869595, 'fraction_numerical': 0.0, 'mean_word_length': 2.7049180327868854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '2136053', 'n_tokens_mistral': 807, 'n_tokens_neox': 798, 'n_words': 160}