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

Payload::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 6
rs 9.4285
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\Channel;
18
19
use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition;
20
use CuyZ\Notiz\Core\Event\Event;
21
use CuyZ\Notiz\Core\Notification\Notification;
22
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessor;
23
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessorFactory;
24
25
/**
26
 * Object passed to a channel object when an event is fired and triggers a
27
 * notification dispatch.
28
 *
29
 * It gives access to:
30
 *
31
 * - The notification instance;
32
 * - The notification definition object;
33
 * - The notification processor;
34
 * - The event instance.
35
 */
36
class Payload
37
{
38
    /**
39
     * @var Notification
40
     */
41
    protected $notification;
42
43
    /**
44
     * @var NotificationDefinition
45
     */
46
    protected $notificationDefinition;
47
48
    /**
49
     * @var Event
50
     */
51
    protected $event;
52
53
    /**
54
     * @var NotificationProcessor
55
     */
56
    protected $notificationProcessor;
57
58
    /**
59
     * @param Notification $notification
60
     * @param NotificationDefinition $notificationDefinition
61
     * @param Event $event
62
     */
63
    public function __construct(Notification $notification, NotificationDefinition $notificationDefinition, Event $event)
64
    {
65
        $this->notification = $notification;
66
        $this->notificationDefinition = $notificationDefinition;
67
        $this->event = $event;
68
        $this->notificationProcessor = NotificationProcessorFactory::get()->getFromNotification($this->notification);
69
    }
70
71
    /**
72
     * @return Notification
73
     */
74
    public function getNotification()
75
    {
76
        return $this->notification;
77
    }
78
79
    /**
80
     * @return NotificationDefinition
81
     */
82
    public function getNotificationDefinition()
83
    {
84
        return $this->notificationDefinition;
85
    }
86
87
    /**
88
     * @return Event
89
     */
90
    public function getEvent()
91
    {
92
        return $this->event;
93
    }
94
95
    /**
96
     * @return NotificationProcessor
97
     */
98
    public function getNotificationProcessor()
99
    {
100
        return $this->notificationProcessor;
101
    }
102
}
103