FormSubmissionCallback::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Processor;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use WebTheory\Saveyour\Contracts\Processor\FormDataProcessorInterface;
7
use WebTheory\Saveyour\Contracts\Report\FormProcessReportInterface;
8
use WebTheory\Saveyour\Processor\Abstracts\AbstractFormDataProcessor;
9
10
class FormSubmissionCallback extends AbstractFormDataProcessor implements FormDataProcessorInterface
11
{
12
    /**
13
     * @var callable
14
     */
15
    protected $callback;
16
17
    public function __construct(string $name, ?array $fields, callable $callback)
18
    {
19
        parent::__construct($name, $fields);
20
21
        $this->callback = $callback;
22
    }
23
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function process(ServerRequestInterface $request, array $results): ?FormProcessReportInterface
28
    {
29
        return ($this->callback)($request, $results, $this);
30
    }
31
}
32