Passed
Push — master ( 204e2b...dee98e )
by Gallice
03:34
created

Helper::getFirstEntityValue()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.2
nc 5
cc 4
eloc 5
nop 2
crap 20
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
    public static function getFirstEntityValue($entityName, array $entities)
14
    {
15
        if (!isset($entities[$entityName][0]['value'])) {
16
            return null;
17
        }
18
19
        $val = $entities[$entityName][0]['value'];
20
21
        return is_array($val) && isset($val['value']) ? $val['value'] : $val;
22
    }
23
}
24