Passed
Pull Request — master (#1801)
by Nico
23:50
created

PmReset::unsetAllInboxReferences()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Admin\Reset\Communication;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Stu\Orm\Repository\ContactRepositoryInterface;
9
use Stu\Orm\Repository\PrivateMessageFolderRepositoryInterface;
10
use Stu\Orm\Repository\PrivateMessageRepositoryInterface;
11
12
final class PmReset implements PmResetInterface
13
{
14
    private PrivateMessageFolderRepositoryInterface $privateMessageFolderRepository;
15
16
    private PrivateMessageRepositoryInterface $privateMessageRepository;
17
18
    private ContactRepositoryInterface $contactRepository;
19
20
    private EntityManagerInterface $entityManager;
21
22
    public function __construct(
23
        PrivateMessageFolderRepositoryInterface $privateMessageFolderRepository,
24
        PrivateMessageRepositoryInterface $privateMessageRepository,
25
        ContactRepositoryInterface $contactRepository,
26
        EntityManagerInterface $entityManager
27
    ) {
28
        $this->privateMessageFolderRepository = $privateMessageFolderRepository;
29
        $this->privateMessageRepository = $privateMessageRepository;
30
        $this->contactRepository = $contactRepository;
31
        $this->entityManager = $entityManager;
32
    }
33
34
    public function unsetAllInboxReferences(): void
35
    {
36
        echo "  - unset all inbox references\n";
37
38
        $this->privateMessageRepository->unsetAllInboxReferences();
39
40
        $this->entityManager->flush();
41
    }
42
43
    public function resetAllNonNpcPmFolders(): void
44
    {
45
        echo "  - deleting all non npc pm folders\n";
46
47
        $this->privateMessageFolderRepository->truncateAllNonNpcFolders();
48
49
        $this->entityManager->flush();
50
    }
51
52
    public function resetPms(): void
53
    {
54
        echo "  - deleting all pms\n";
55
56
        $this->privateMessageRepository->truncateAllPrivateMessages();
57
58
        $this->entityManager->flush();
59
    }
60
61
    public function deleteAllContacts(): void
62
    {
63
        echo "  - deleting all contacts\n";
64
65
        $this->contactRepository->truncateAllContacts();
66
67
        $this->entityManager->flush();
68
    }
69
}
70