Passed
Push — master ( 4c5faf...429320 )
by Chris
04:23
created

AbstractFieldOperationCache::updateSuccessful()   A

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Controllers;
4
5
use JsonSerializable;
6
use WebTheory\Saveyour\Contracts\FieldOperationCacheInterface;
7
8
abstract class AbstractFieldOperationCache implements FieldOperationCacheInterface, JsonSerializable
9
{
10
    /**
11
     *
12
     */
13
    protected $results = [
14
        'request_var_present' => false,
15
        'sanitized_input_value' => null,
16
        'update_attempted' => false,
17
        'update_successful' => false,
18
        'rule_violations' => [],
19
    ];
20
21
    /**
22
     * @var bool
23
     */
24
    protected $requestVarPresent = false;
25
26
    /**
27
     * @var mixed
28
     */
29
    protected $sanitizedInputValue;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $updateAttempted = false;
35
36
    /**
37
     * @var bool
38
     */
39
    protected $updateSuccessful = false;
40
41
    /**
42
     * @var array
43
     */
44
    protected $ruleViolations = [];
45
46
    /**
47
     *
48
     */
49 6
    public function requestVarPresent(): bool
50
    {
51 6
        return $this->results['request_var_present'];
52
    }
53
54
    /**
55
     *
56
     */
57 36
    public function sanitizedInputValue()
58
    {
59 36
        return $this->results['sanitized_input_value'];
60
    }
61
62
    /**
63
     *
64
     */
65 15
    public function updateAttempted(): bool
66
    {
67 15
        return $this->results['update_attempted'];
68
    }
69
70
    /**
71
     *
72
     */
73 27
    public function updateSuccessful(): bool
74
    {
75 27
        return $this->results['update_successful'];
76
    }
77
78
    /**
79
     *
80
     */
81 36
    public function ruleViolations(): array
82
    {
83 36
        return $this->results['rule_violations'];
84
    }
85
86
    /**
87
     *
88
     */
89
    public function toArray()
90
    {
91
        return (array) $this;
92
    }
93
94
    /**
95
     *
96
     */
97
    public function toJson()
98
    {
99
        return json_encode($this);
100
    }
101
102
    /**
103
     *
104
     */
105
    public function jsonSerialize()
106
    {
107
        return $this;
108
    }
109
}
110