Signal   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
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
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\Definition\Tree\EventGroup\Event\Connection;
19
20
use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent;
21
use CuyZ\Notiz\Core\Event\Runner\EventRunner;
22
use CuyZ\Notiz\Service\Container;
23
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\SignalSlot\Dispatcher was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
25
class Signal extends AbstractDefinitionComponent implements Connection
26
{
27
    /**
28
     * @var string
29
     *
30
     * @validate NotEmpty
31
     */
32
    protected $className;
33
34
    /**
35
     * @var string
36
     *
37
     * @validate NotEmpty
38
     */
39
    protected $name;
40
41
    /**
42
     * @param string $className
43
     * @param string $name
44
     */
45
    public function __construct(string $className, string $name)
46
    {
47
        $this->className = $className;
48
        $this->name = $name;
49
    }
50
51
    /**
52
     * Registers the signal in TYPO3 signal slot dispatcher.
53
     *
54
     * @param EventRunner $eventRunner
55
     */
56
    public function register(EventRunner $eventRunner)
57
    {
58
        /** @var Dispatcher $signalSlotDispatcher */
59
        $signalSlotDispatcher = Container::get(Dispatcher::class);
60
61
        $signalSlotDispatcher->connect(
62
            $this->className,
63
            $this->name,
64
            ...$eventRunner->getCallable()
65
        );
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getClassName(): string
72
    {
73
        return $this->className;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getName(): string
80
    {
81
        return $this->name;
82
    }
83
}
84