FormProcessReportBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Report\Builder;
4
5
use WebTheory\Saveyour\Contracts\Report\Builder\FormProcessReportBuilderInterface;
6
use WebTheory\Saveyour\Contracts\Report\FormProcessReportInterface;
7
use WebTheory\Saveyour\Report\FormProcessReport;
8
9
class FormProcessReportBuilder implements FormProcessReportBuilderInterface
10
{
11
    protected $results;
12
13 9
    public function __construct(FormProcessReportInterface $previous = null)
14
    {
15 9
        if ($previous) {
16
            $this->results = $previous->results();
17
        }
18
    }
19
20
    /**
21
     * @return $this
22
     */
23 9
    public function withProcessResult(string $process, $result): FormProcessReportBuilderInterface
24
    {
25 9
        $this->results[$process] = $result;
26
27 9
        return $this;
28
    }
29
30 9
    public function build(): FormProcessReportInterface
31
    {
32 9
        return new FormProcessReport($this->results);
33
    }
34
}
35