Passed
Push — master ( 4fcae8...b8fbdf )
by Romain
03:40
created

getNotificationFromIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\Core\Notification\Processor;
18
19
use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition;
20
use CuyZ\Notiz\Core\Notification\Notification;
21
use CuyZ\Notiz\Domain\Repository\EntityNotificationRepository;
22
23
abstract class EntityNotificationProcessor extends NotificationProcessor
24
{
25
    /**
26
     * The repository needs to be injected in the child class.
27
     *
28
     * @var EntityNotificationRepository
29
     */
30
    protected $notificationRepository;
31
32
    /**
33
     * @param EventDefinition $definition
34
     * @return Notification[]
35
     */
36
    public function getNotificationsFromEventDefinition(EventDefinition $definition)
37
    {
38
        return $this->notificationRepository
39
            ->findFromEventDefinition($definition)
40
            ->toArray();
41
    }
42
43
    /**
44
     * @param string $identifier
45
     * @return Notification|object
46
     */
47
    public function getNotificationFromIdentifier($identifier)
48
    {
49
        return $this->notificationRepository
50
            ->findByIdentifier($identifier);
51
    }
52
53
    /**
54
     * @return Notification[]
55
     */
56
    public function getAllNotifications()
57
    {
58
        return $this->notificationRepository
59
            ->findAll()
60
            ->toArray();
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getTotalNumber()
67
    {
68
        return $this->notificationRepository
69
            ->findAll()
70
            ->count();
71
    }
72
}
73