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

FieldOperationCache::offsetExists()   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 1
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 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