Completed
Push — master ( f93802...a3beff )
by Paweł
34:14
created

getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\EventSubscriber;
16
17
use SWP\Bundle\ContentBundle\ArticleEvents;
18
use SWP\Bundle\ContentBundle\Event\ArticleEvent;
19
use SWP\Component\Rule\Processor\RuleProcessorInterface;
20
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
22
class ProcessArticleRulesSubscriber implements EventSubscriberInterface
23
{
24
    /**
25
     * @var RuleProcessorInterface
26
     */
27
    private $ruleProcessor;
28
29
    /**
30
     * ProcessArticleRulesSubscriber constructor.
31
     *
32
     * @param RuleProcessorInterface $ruleProcessor
33
     */
34 8
    public function __construct(RuleProcessorInterface $ruleProcessor)
35
    {
36 8
        $this->ruleProcessor = $ruleProcessor;
37 8
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 73
    public static function getSubscribedEvents()
43
    {
44
        return [
45 73
            ArticleEvents::PRE_CREATE => 'processRules',
46
        ];
47
    }
48
49
    /**
50
     * @param ArticleEvent $event
51
     */
52 6
    public function processRules(ArticleEvent $event)
53
    {
54 6
        $this->ruleProcessor->process($event->getArticle());
0 ignored issues
show
Documentation introduced by
$event->getArticle() is of type object<SWP\Bundle\Conten...Model\ArticleInterface>, but the function expects a object<SWP\Component\Rul...l\RuleSubjectInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55 6
    }
56
}
57