Passed
Push — master ( bb9802...b428f1 )
by Julito
09:11
created

MessageRepository::update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Repository;
8
9
use Chamilo\CoreBundle\Entity\Message;
10
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
11
use Doctrine\Persistence\ManagerRegistry;
12
13
class MessageRepository extends ServiceEntityRepository
14
{
15
    public function __construct(ManagerRegistry $registry)
16
    {
17
        parent::__construct($registry, Message::class);
18
    }
19
20
    public function update(Message $message, bool $andFlush = true): void
21
    {
22
        $this->getEntityManager()->persist($message);
23
        if ($andFlush) {
24
            $this->getEntityManager()->flush();
25
        }
26
    }
27
28
    public function delete(Message $message): void
29
    {
30
        $this->getEntityManager()->remove($message);
31
        $this->getEntityManager()->flush();
32
    }
33
}
34