Payload::getNotification()   A
last analyzed

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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Core\Channel;
19
20
use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition;
21
use CuyZ\Notiz\Core\Event\Event;
22
use CuyZ\Notiz\Core\Notification\Notification;
23
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessor;
24
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessorFactory;
25
26
/**
27
 * Object passed to a channel object when an event is fired and triggers a
28
 * notification dispatch.
29
 *
30
 * It gives access to:
31
 *
32
 * - The notification instance;
33
 * - The notification definition object;
34
 * - The notification processor;
35
 * - The event instance.
36
 */
37
class Payload
38
{
39
    /**
40
     * @var Notification
41
     */
42
    protected $notification;
43
44
    /**
45
     * @var NotificationDefinition
46
     */
47
    protected $notificationDefinition;
48
49
    /**
50
     * @var Event
51
     */
52
    protected $event;
53
54
    /**
55
     * @var NotificationProcessor
56
     */
57
    protected $notificationProcessor;
58
59
    /**
60
     * @param Notification $notification
61
     * @param NotificationDefinition $notificationDefinition
62
     * @param Event $event
63
     */
64
    public function __construct(Notification $notification, NotificationDefinition $notificationDefinition, Event $event)
65
    {
66
        $this->notification = $notification;
67
        $this->notificationDefinition = $notificationDefinition;
68
        $this->event = $event;
69
        $this->notificationProcessor = NotificationProcessorFactory::get()->getFromNotification($this->notification);
0 ignored issues
show
Bug introduced by
It seems like getFromNotification() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
        $this->notificationProcessor = NotificationProcessorFactory::get()->/** @scrutinizer ignore-call */ getFromNotification($this->notification);
Loading history...
70
    }
71
72
    /**
73
     * @return Notification
74
     */
75
    public function getNotification(): Notification
76
    {
77
        return $this->notification;
78
    }
79
80
    /**
81
     * @return NotificationDefinition
82
     */
83
    public function getNotificationDefinition(): NotificationDefinition
84
    {
85
        return $this->notificationDefinition;
86
    }
87
88
    /**
89
     * @return Event
90
     */
91
    public function getEvent(): Event
92
    {
93
        return $this->event;
94
    }
95
96
    /**
97
     * @return NotificationProcessor
98
     */
99
    public function getNotificationProcessor(): NotificationProcessor
100
    {
101
        return $this->notificationProcessor;
102
    }
103
}
104