Passed
Push — master ( 4595aa...20e07b )
by Romain
06:34
created

NotificationProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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
22
/**
23
 * A notification processor will be used by services to perform actions or fetch
24
 * data related to a given notification type.
25
 *
26
 * Notification fetching
27
 * ---------------------
28
 *
29
 * The main goal of the processor is to fetch notification entries. You  need to
30
 * implement the following methods that must return the correct notifications:
31
 *
32
 * @see \CuyZ\Notiz\Core\Notification\Processor\NotificationProcessor::getNotificationsFromEventDefinition
33
 * @see \CuyZ\Notiz\Core\Notification\Processor\NotificationProcessor::getAllNotifications
34
 */
35
abstract class NotificationProcessor
36
{
37
    /**
38
     * @var string
39
     */
40
    protected $notificationClassName;
41
42
    /**
43
     * WARNING
44
     * -------
45
     *
46
     * If you need to override the constructor, do not forget to call:
47
     * `parent::__construct`
48
     *
49
     * @param string $notificationClassName
50
     */
51
    public function __construct($notificationClassName)
52
    {
53
        $this->notificationClassName = $notificationClassName;
54
    }
55
56
    /**
57
     * Returns the notification instances after a filter on the given event
58
     * definition has been applied.
59
     *
60
     * @param EventDefinition $eventDefinition
61
     * @return Notification[]
62
     */
63
    abstract public function getNotificationsFromEventDefinition(EventDefinition $eventDefinition);
64
65
    /**
66
     * Returns all notification instances.
67
     *
68
     * @return Notification[]
69
     */
70
    abstract public function getAllNotifications();
71
72
    /**
73
     * @return int
74
     */
75
    abstract public function getTotalNumber();
76
}
77