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

PmReset   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 56
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A resetPms() 0 7 1
A deleteAllContacts() 0 7 1
A unsetAllInboxReferences() 0 7 1
A resetAllNonNpcPmFolders() 0 7 1
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