Passed
Push — develop ( ba1535...9827cb )
by BENARD
02:20
created

Messager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A send() 0 10 1
1
<?php
2
3
namespace ProjetNormandie\MessageBundle\Service;
4
5
use ProjetNormandie\MessageBundle\Entity\Message;
6
use ProjetNormandie\MessageBundle\Repository\MessageRepository;
7
8
/**
9
 * Proxy to send a private message
10
 */
11
class Messager
12
{
13
    private MessageRepository $messageRepository;
14
15
    /**
16
     * Message constructor.
17
     * @param MessageRepository $messageRepository
18
     */
19
    public function __construct(MessageRepository $messageRepository)
20
    {
21
        $this->messageRepository = $messageRepository;
22
    }
23
24
25
    /**
26
     * @param string $object
27
     * @param string $message
28
     * @param        $sender
29
     * @param        $recipient
30
     * @param string $type
31
     * @param bool   $isDeletedSender
32
     */
33
    public function send(string $object, string $message, $sender, $recipient, string $type = 'DEFAULT', bool $isDeletedSender = true)
34
    {
35
        $entity = new Message();
36
        $entity->setType($type);
37
        $entity->setObject($object);
38
        $entity->setMessage($message);
39
        $entity->setSender($sender);
40
        $entity->setRecipient($recipient);
41
        $entity->setIsDeletedSender($isDeletedSender);
42
        $this->messageRepository->save($entity);
43
    }
44
}
45