ProcessedFieldReport::updateAttempted()   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;
4
5
use WebTheory\Saveyour\Contracts\Report\ProcessedFieldReportInterface;
6
7
class ProcessedFieldReport implements ProcessedFieldReportInterface
8
{
9
    protected $sanitizedInputValue;
10
11
    protected bool $updateAttempted = false;
12
13
    protected bool $updateSuccessful = false;
14
15 45
    public function __construct(
16
        $sanitizedInputValue = null,
17
        bool $updateAttempted = false,
18
        bool $updateSuccessful = false
19
    ) {
20 45
        $this->sanitizedInputValue = $sanitizedInputValue;
21 45
        $this->updateAttempted = $updateAttempted;
22 45
        $this->updateSuccessful = $updateSuccessful;
23
    }
24
25 9
    public function sanitizedInputValue()
26
    {
27 9
        return $this->sanitizedInputValue;
28
    }
29
30 9
    public function updateAttempted(): bool
31
    {
32 9
        return $this->updateAttempted;
33
    }
34
35 9
    public function updateSuccessful(): bool
36
    {
37 9
        return $this->updateSuccessful;
38
    }
39
40
    public function toArray()
41
    {
42
        return [
43
            'sanitized_input_value' => $this->sanitizedInputValue,
44
            'update_attempted' => $this->updateAttempted,
45
            'update_successful' => $this->updateSuccessful,
46
        ];
47
    }
48
49
    public static function voided(): ProcessedFieldReportInterface
50
    {
51
        return new static(null, false, false);
52
    }
53
}
54