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

Signal   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getClassName() 0 3 1
A register() 0 9 1
A getName() 0 3 1
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\Definition\Tree\EventGroup\Event\Connection;
18
19
use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent;
20
use CuyZ\Notiz\Core\Event\Runner\EventRunner;
21
use CuyZ\Notiz\Service\Container;
22
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
23
24
class Signal extends AbstractDefinitionComponent implements Connection
25
{
26
    /**
27
     * @var string
28
     *
29
     * @validate NotEmpty
30
     */
31
    protected $className;
32
33
    /**
34
     * @var string
35
     *
36
     * @validate NotEmpty
37
     */
38
    protected $name;
39
40
    /**
41
     * @param string $className
42
     * @param string $name
43
     */
44
    public function __construct($className, $name)
45
    {
46
        $this->className = $className;
47
        $this->name = $name;
48
    }
49
50
    /**
51
     * Registers the signal in TYPO3 signal slot dispatcher.
52
     *
53
     * @param EventRunner $eventRunner
54
     */
55
    public function register(EventRunner $eventRunner)
56
    {
57
        /** @var Dispatcher $signalSlotDispatcher */
58
        $signalSlotDispatcher = Container::get(Dispatcher::class);
59
60
        $signalSlotDispatcher->connect(
61
            $this->className,
62
            $this->name,
63
            ...$eventRunner->getCallable()
0 ignored issues
show
Bug introduced by
$eventRunner->getCallable() is expanded, but the parameter $slotClassNameOrObject of TYPO3\CMS\Extbase\SignalSlot\Dispatcher::connect() does not expect variable arguments. ( Ignorable by Annotation )

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

63
            /** @scrutinizer ignore-type */ ...$eventRunner->getCallable()
Loading history...
64
        );
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getClassName()
71
    {
72
        return $this->className;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getName()
79
    {
80
        return $this->name;
81
    }
82
}
83