ProcessedFormReport::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Report;
4
5
use WebTheory\Saveyour\Contracts\Report\FormShieldReportInterface;
6
use WebTheory\Saveyour\Contracts\Report\ProcessedFormReportInterface;
7
8
class ProcessedFormReport implements ProcessedFormReportInterface
9
{
10
    protected FormShieldReportInterface $shieldReport;
11
12
    protected array $inputReports = [];
13
14
    protected array $processReports = [];
15
16 45
    public function __construct(FormShieldReportInterface $shieldReport, array $inputReports, array $processReports)
17
    {
18 45
        $this->shieldReport = $shieldReport;
19 45
        $this->inputReports = $inputReports;
20 45
        $this->processReports = $processReports;
21
    }
22
23 6
    public function shieldReport(): FormShieldReportInterface
24
    {
25 6
        return $this->shieldReport;
26
    }
27
28 12
    public function inputReports(): array
29
    {
30 12
        return $this->inputReports;
31
    }
32
33 6
    public function processReports(): array
34
    {
35 6
        return $this->processReports;
36
    }
37
38
    public function submissionIsValid(): bool
39
    {
40
        foreach ($this->inputReports as $report) {
41
            if (!$report->submissionIsValid()) {
42
                return false;
43
            }
44
        }
45
46
        return true;
47
    }
48
}
49