DispatchEventAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 24
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Action;
13
14
use LightSaml\Context\ContextInterface;
15
use LightSaml\Event\BeforeEncrypt;
16
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
18
class DispatchEventAction implements ActionInterface
19
{
20
    /** @var EventDispatcherInterface */
21
    protected $eventDispatcher;
22
23
    /**
24
     * @param EventDispatcherInterface $eventDispatcher
25
     */
26 3
    public function __construct(EventDispatcherInterface $eventDispatcher)
27
    {
28 3
        $this->eventDispatcher = $eventDispatcher;
29 3
    }
30
31
    /**
32
     * @param ContextInterface $context
33
     *
34
     * @return void
35
     */
36 2
    public function execute(ContextInterface $context)
37
    {
38 2
        $event = new BeforeEncrypt($context);
39 2
        $this->eventDispatcher->dispatch($event, $event::NAME);
0 ignored issues
show
Documentation introduced by
$event is of type object<LightSaml\Event\BeforeEncrypt>, but the function expects a object<Symfony\Contracts\EventDispatcher\object>.

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...
40 2
    }
41
}
42