ProcessedFieldReportBuilder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 84.21%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 53
ccs 16
cts 19
cp 0.8421
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A withUpdateSuccessful() 0 5 1
A build() 0 6 1
A withUpdateAttempted() 0 5 1
A withSanitizedInputValue() 0 5 1
1
<?php
2
3
namespace WebTheory\Saveyour\Report\Builder;
4
5
use WebTheory\Saveyour\Contracts\Report\Builder\ProcessedFieldReportBuilderInterface;
6
use WebTheory\Saveyour\Contracts\Report\ProcessedFieldReportInterface;
7
use WebTheory\Saveyour\Report\ProcessedFieldReport;
8
9
class ProcessedFieldReportBuilder implements ProcessedFieldReportBuilderInterface
10
{
11
    protected $sanitizedInputValue = null;
12
13
    protected bool $updateAttempted = false;
14
15
    protected bool $updateSuccessful = false;
16
17 6
    public function __construct(?ProcessedFieldReportInterface $previous = null)
18
    {
19 6
        if ($previous) {
20
            $this->sanitizedInputValue = $previous->sanitizedInputValue();
21
            $this->updateAttempted = $previous->updateAttempted();
22
            $this->updateSuccessful = $previous->updateSuccessful();
23
        }
24
    }
25
26
    /**
27
     * @return $this
28
     */
29 6
    public function withSanitizedInputValue($value): ProcessedFieldReportBuilder
30
    {
31 6
        $this->sanitizedInputValue = $value;
32
33 6
        return $this;
34
    }
35
36
    /**
37
     * @return $this
38
     */
39 5
    public function withUpdateAttempted(bool $result): ProcessedFieldReportBuilder
40
    {
41 5
        $this->updateAttempted = $result;
42
43 5
        return $this;
44
    }
45
46
    /**
47
     * @return $this
48
     */
49 5
    public function withUpdateSuccessful(bool $result): ProcessedFieldReportBuilder
50
    {
51 5
        $this->updateSuccessful = $result;
52
53 5
        return $this;
54
    }
55
56 6
    public function build(): ProcessedFieldReportInterface
57
    {
58 6
        return new ProcessedFieldReport(
59 6
            $this->sanitizedInputValue,
60 6
            $this->updateAttempted,
61 6
            $this->updateSuccessful
62
        );
63
    }
64
}
65