ArrayReference::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Cascade\Mapper\Field\Reference;
4
5
class ArrayReference implements ReferenceInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $field;
11
12
    /**
13
     * @param string $field
14
     */
15 6
    public function __construct($field)
16
    {
17 6
        $this->field = $field;
18 6
    }
19
20 2
    public function getValue($instance)
21
    {
22 2
        $field = $this->field;
23
24 2
        if (array_key_exists($field, $instance)) {
25 1
            return $instance[$field];
26
        }
27
28 1
        return null;
29
    }
30
31 1
    public function setValue($instance, $value)
32
    {
33 1
        $instance[$this->field] = $value;
34
35 1
        return $instance;
36
    }
37
}
38