Helper::getFirstEntityValue()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.2
ccs 5
cts 5
cp 1
nc 5
cc 4
eloc 5
nop 2
crap 4
1
<?php
2
3
namespace Tgallice\Wit;
4
5
class Helper
6
{
7
    /**
8
     * @param $entityName
9
     * @param array $entities
10
     *
11
     * @return mixed
12
     */
13 2
    public static function getFirstEntityValue($entityName, array $entities)
14
    {
15 2
        if (!isset($entities[$entityName][0]['value'])) {
16 1
            return null;
17
        }
18
19 1
        $val = $entities[$entityName][0]['value'];
20
21 1
        return is_array($val) && isset($val['value']) ? $val['value'] : $val;
22
    }
23
}
24