ArrayReference::getValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
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