Passed
Pull Request — master (#135)
by Romain
03:00
created

getNotificationDefinitionIdentifier()   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 0
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\Controller\Backend\Manager\Notification;
18
19
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties;
20
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\EntitySlackNotification;
21
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\Service\EntitySlackMessageBuilder;
22
use CuyZ\Notiz\Domain\Notification\Slack\SlackNotification;
23
24
class ShowEntitySlackController extends ShowNotificationController
25
{
26
    /**
27
     * @var SlackNotification
28
     */
29
    protected $notification;
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function showAction()
35
    {
36
        parent::showAction();
37
38
        $message = $this->notification->getMessage();
39
40
        if ($this->notification->hasEventDefinition()) {
41
            $payload = $this->getPreviewPayload();
42
43
            if ($payload->getEvent() instanceof ProvidesExampleProperties) {
44
                $builder = $this->objectManager->get(EntitySlackMessageBuilder::class, $payload);
0 ignored issues
show
Unused Code introduced by
The call to TYPO3\CMS\Extbase\Object...ManagerInterface::get() has too many arguments starting with $payload. ( Ignorable by Annotation )

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

44
                /** @scrutinizer ignore-call */ 
45
                $builder = $this->objectManager->get(EntitySlackMessageBuilder::class, $payload);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
45
                $message = $builder->getMessage();
46
            }
47
        }
48
49
        $this->view->assign('message', $message);
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getNotificationDefinitionIdentifier()
56
    {
57
        return EntitySlackNotification::getDefinitionIdentifier();
58
    }
59
}
60