AbstractBinding::send()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 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\Binding;
13
14
use LightSaml\Context\Profile\MessageContext;
15
use LightSaml\Event\BindingMessageReceived;
16
use LightSaml\Event\BindingMessageSent;
17
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
18
use Symfony\Component\HttpFoundation\Request;
19
20
abstract class AbstractBinding
21
{
22
    /** @var EventDispatcherInterface|null */
23
    protected $eventDispatcher;
24
25
    /**
26
     * @param EventDispatcherInterface|null $eventDispatcher
27
     *
28
     * @return AbstractBinding
29
     */
30 11
    public function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null)
31
    {
32 11
        $this->eventDispatcher = $eventDispatcher;
33
34 11
        return $this;
35
    }
36
37
    /**
38
     * @return null|\Symfony\Component\EventDispatcher\EventDispatcherInterface
39
     */
40 4
    public function getEventDispatcher()
41
    {
42 4
        return $this->eventDispatcher;
43
    }
44
45
    /**
46
     * @param string $messageString
47
     */
48 3
    protected function dispatchReceive($messageString)
49
    {
50 3
        if ($this->eventDispatcher) {
51 3
            $event = new BindingMessageReceived($messageString);
52 3
            $this->eventDispatcher->dispatch($event, $event::NAME);
0 ignored issues
show
Documentation introduced by
$event is of type object<LightSaml\Event\BindingMessageReceived>, 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...
53
        }
54 3
    }
55
56
    /**
57
     * @param string $messageString
58
     */
59 6
    protected function dispatchSend($messageString)
60
    {
61 6
        if ($this->eventDispatcher) {
62 3
            $event = new BindingMessageSent($messageString);
63 3
            $this->eventDispatcher->dispatch($event, $event::NAME);
0 ignored issues
show
Documentation introduced by
$event is of type object<LightSaml\Event\BindingMessageSent>, 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...
64
        }
65 6
    }
66
67
    /**
68
     * @param MessageContext $context
69
     * @param null|string    $destination
70
     *
71
     * @return \Symfony\Component\HttpFoundation\Response
72
     */
73
    abstract public function send(MessageContext $context, $destination = null);
74
75
    /**
76
     * @param Request        $request
77
     * @param MessageContext $context
78
     */
79
    abstract public function receive(Request $request, MessageContext $context);
80
}
81