Passed
Push — 4.x ( dee8fb...538515 )
by Loïc
02:55
created

AbstractAsyncProcessor::end()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the DataImporter package.
7
 *
8
 * (c) Loïc Sapone <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace IQ2i\DataImporter\Bundle\Processor;
15
16
use IQ2i\DataImporter\Bundle\Messenger\AsyncMessage;
17
use IQ2i\DataImporter\Exchange\Message;
18
use IQ2i\DataImporter\Processor\ProcessorInterface;
19
use Symfony\Component\Messenger\MessageBusInterface;
20
use Symfony\Contracts\Service\Attribute\Required;
21
22
abstract class AbstractAsyncProcessor implements ProcessorInterface
23
{
24
    private ?MessageBusInterface $bus = null;
25
26 1
    public function begin(Message $message)
27
    {
28 1
    }
29
30 1
    public function item(Message $message)
31
    {
32 1
        $this->bus->dispatch(new AsyncMessage($message));
0 ignored issues
show
Bug introduced by
The method dispatch() does not exist on null. ( Ignorable by Annotation )

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

32
        $this->bus->/** @scrutinizer ignore-call */ 
33
                    dispatch(new AsyncMessage($message));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
    }
34
35
    abstract public function processItem(AsyncMessage $message);
36
37 1
    public function end(Message $message)
38
    {
39 1
    }
40
41 1
    #[Required]
42
    public function setBus(MessageBusInterface $bus): void
43
    {
44 1
        $this->bus = $bus;
45
    }
46
}
47