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

FieldOperationCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 51
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A offsetGet() 0 3 1
A __construct() 0 12 1
A jsonSerialize() 0 3 1
A offsetExists() 0 3 1
1
<?php
2
3
namespace WebTheory\Saveyour\Controllers;
4
5
use ArrayAccess;
6
use JsonSerializable;
7
use WebTheory\Saveyour\Concerns\ImmutableObjectTrait;
8
use WebTheory\Saveyour\Contracts\FieldOperationCacheInterface;
9
10
class FieldOperationCache extends AbstractFieldOperationCache implements FieldOperationCacheInterface, ArrayAccess, JsonSerializable
11
{
12
    use ImmutableObjectTrait;
13
14
    /**
15
     *
16
     */
17 51
    public function __construct(
18
        bool $requestVarPresent,
19
        $sanitizedInputValue,
20
        bool $updateAttempted,
21
        bool $updateSuccessful,
22
        array $ruleViolations
23
    ) {
24 51
        $this->results['request_var_present'] = $requestVarPresent;
25 51
        $this->results['sanitized_input_value'] = $sanitizedInputValue;
26 51
        $this->results['update_attempted'] = $updateAttempted;
27 51
        $this->results['update_successful'] = $updateSuccessful;
28 51
        $this->results['rule_violations'] = $ruleViolations;
29 51
    }
30
31
    /**
32
     *
33
     */
34 6
    public function toArray()
35
    {
36 6
        return $this->results;
37
    }
38
39
    /**
40
     *
41
     */
42 3
    public function offsetExists($offset)
43
    {
44 3
        return isset($this->results[$offset]);
45
    }
46
47
    /**
48
     *
49
     */
50 3
    public function offsetGet($offset)
51
    {
52 3
        return $this->results[$offset];
53
    }
54
55
    /**
56
     *
57
     */
58 6
    public function jsonSerialize()
59
    {
60 6
        return $this->toArray();
61
    }
62
}
63