EventDrivenProcessor::handleTarget()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of Transfer.
5
 *
6
 * For the full copyright and license information, please view the LICENSE file located
7
 * in the root directory.
8
 */
9
10
namespace Transfer\Processor;
11
12
use Psr\Log\LoggerInterface;
13
use Symfony\Component\EventDispatcher\EventDispatcher;
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
use Transfer\Adapter\SourceAdapterInterface;
17
use Transfer\Adapter\TargetAdapterInterface;
18
use Transfer\Adapter\Transaction\Request;
19
use Transfer\Event as Events;
20
use Transfer\Event\TransferEvents;
21
use Transfer\Procedure\Procedure;
22
use Transfer\Processor\EventSubscriber\Logger;
23
use Transfer\Storage\StorageInterface;
24
use Transfer\Worker\WorkerInterface;
25
26
/**
27
 * Partial processor implementation with event functionality.
28
 */
29
abstract class EventDrivenProcessor extends Processor
30
{
31
    /**
32
     * @var EventDispatcherInterface Event dispatcher
33
     */
34
    protected $dispatcher;
35
36 13
    public function __construct()
37
    {
38 13
        parent::__construct();
39
40 13
        $this->dispatcher = new EventDispatcher();
41 13
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 2
    public function setEventDispatcher(EventDispatcherInterface $dispatcher)
47
    {
48 2
        $this->dispatcher = $dispatcher;
49 2
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function addSubscriber(EventSubscriberInterface $subscriber)
55
    {
56 1
        $this->dispatcher->addSubscriber($subscriber);
57 1
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 5
    public function addListener($eventName, $listener, $priority = 0)
63
    {
64 5
        $this->dispatcher->addListener($eventName, $listener, $priority);
65 5
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 1
    public function setLogger(LoggerInterface $logger)
71
    {
72 1
        parent::setLogger($logger);
73
74 1
        $this->addSubscriber(new Logger($logger));
75 1
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 10
    public function process()
81
    {
82 10
        $this->dispatcher->dispatch(TransferEvents::PRE_PROCESS, new Events\PreProcessEvent($this));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PreProcessEvent($this) is of type object<Transfer\Event\PreProcessEvent>, but the function expects a null|string.

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...
83
84 10
        parent::process();
85
86 8
        $this->dispatcher->dispatch(TransferEvents::POST_PROCESS, new Events\PostProcessEvent($this));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PostProcessEvent($this) is of type object<Transfer\Event\PostProcessEvent>, but the function expects a null|string.

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...
87 8
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92 10
    protected function handleProcedureOuter(Procedure $procedure)
93
    {
94 10
        $this->dispatcher->dispatch(TransferEvents::PRE_PROCEDURE, new Events\PreProcedureEvent($procedure));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PreProcedureEvent($procedure) is of type object<Transfer\Event\PreProcedureEvent>, but the function expects a null|string.

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...
95
96 10
        parent::handleProcedureOuter($procedure);
97
98 8
        $this->dispatcher->dispatch(TransferEvents::POST_PROCEDURE, new Events\PostProcedureEvent($procedure, $this));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\Post...vent($procedure, $this) is of type object<Transfer\Event\PostProcedureEvent>, but the function expects a null|string.

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...
99 8
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104 8
    protected function handleSource(SourceAdapterInterface $adapter, Request $request)
105
    {
106 8
        $this->dispatcher->dispatch(TransferEvents::PRE_ADAPTER_RECEIVE, new Events\PreAdapterReceiveEvent($adapter, $request));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PreA...ent($adapter, $request) is of type object<Transfer\Event\PreAdapterReceiveEvent>, but the function expects a null|string.

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...
107
108 8
        $response = parent::handleSource($adapter, $request);
109
110 7
        $this->dispatcher->dispatch(
111 7
            TransferEvents::POST_ADAPTER_RECEIVE,
112 7
            new Events\PostAdapterReceiveEvent($adapter, $response, 0.0)
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\Post...dapter, $response, 0.0) is of type object<Transfer\Event\PostAdapterReceiveEvent>, but the function expects a null|string.

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...
113 7
        );
114
115 7
        return $response;
116
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121 6
    protected function handleWorker(WorkerInterface $worker, $object, StorageInterface $storage)
122
    {
123 6
        $this->dispatcher->dispatch(TransferEvents::PRE_WORKER, new Events\PreWorkerEvent($worker, $object));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PreW...Event($worker, $object) is of type object<Transfer\Event\PreWorkerEvent>, but the function expects a null|string.

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...
124
125 6
        $modifiedObject = parent::handleWorker($worker, $object, $storage);
126
127 6
        $this->dispatcher->dispatch(TransferEvents::POST_WORKER, new Events\PostWorkerEvent($worker, $modifiedObject, 0.0));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\Post..., $modifiedObject, 0.0) is of type object<Transfer\Event\PostWorkerEvent>, but the function expects a null|string.

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...
128
129 6
        return $modifiedObject;
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135 6
    protected function handleTarget(TargetAdapterInterface $adapter, Request $request)
136
    {
137 6
        $this->dispatcher->dispatch(TransferEvents::PRE_ADAPTER_SEND, new Events\PreAdapterSendEvent($adapter, $request));
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\PreA...ent($adapter, $request) is of type object<Transfer\Event\PreAdapterSendEvent>, but the function expects a null|string.

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...
138
139 6
        $response = parent::handleTarget($adapter, $request);
140
141 5
        $this->dispatcher->dispatch(TransferEvents::POST_ADAPTER_SEND, new Events\PostAdapterSendEvent(
0 ignored issues
show
Documentation introduced by
new \Transfer\Event\Post...equest, $response, 0.0) is of type object<Transfer\Event\PostAdapterSendEvent>, but the function expects a null|string.

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...
142 6
            $adapter, $request, $response, 0.0
143 5
        ));
144
145 5
        return $response;
146
    }
147
}
148