CallbackProcessor   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 76.92%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 33
ccs 10
cts 13
cp 0.7692
rs 10
wmc 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A end() 0 4 2
A begin() 0 4 2
A item() 0 4 2
A __construct() 0 5 4
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\Processor;
15
16
use IQ2i\DataImporter\Exchange\Message;
17
18
class CallbackProcessor implements ProcessorInterface
19
{
20
    private readonly ?\Closure $begin;
21
22
    private readonly ?\Closure $item;
23
24
    private readonly ?\Closure $end;
25
26 1
    public function __construct(?callable $begin = null, ?callable $item = null, ?callable $end = null)
27
    {
28 1
        $this->begin = $begin ? $begin(...) : null;
0 ignored issues
show
Bug introduced by
The property begin is declared read-only in IQ2i\DataImporter\Processor\CallbackProcessor.
Loading history...
29 1
        $this->item = $item ? $item(...) : null;
0 ignored issues
show
Bug introduced by
The property item is declared read-only in IQ2i\DataImporter\Processor\CallbackProcessor.
Loading history...
30 1
        $this->end = $end ? $end(...) : null;
0 ignored issues
show
Bug introduced by
The property end is declared read-only in IQ2i\DataImporter\Processor\CallbackProcessor.
Loading history...
31
    }
32
33 1
    public function begin(Message $message): void
34
    {
35 1
        if (null !== $this->begin) {
36
            ($this->begin)($message);
37
        }
38
    }
39
40 1
    public function item(Message $message): void
41
    {
42 1
        if (null !== $this->item) {
43
            ($this->item)($message);
44
        }
45
    }
46
47 1
    public function end(Message $message): void
48
    {
49 1
        if (null !== $this->end) {
50
            ($this->end)($message);
51
        }
52
    }
53
}
54