Passed
Push — master ( 2ea67c...f4db78 )
by Chris
39:33
created

RepositoryCommitment::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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