Completed
Push — master ( 125b2c...072910 )
by Vitaliy
02:55
created

ArrayDataRow::extractCellValue()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
rs 8.7624
cc 5
eloc 15
nc 5
nop 1
1
<?php
2
namespace Nayjest\Grids;
3
4
class ArrayDataRow extends DataRow
5
{
6
    /**
7
     * {@inheritdoc}
8
     */
9
    protected function extractCellValue($fieldName)
10
    {
11
        if (strpos($fieldName, '.') !== false) {
12
            $parts = explode('.', $fieldName);
13
            $res = $this->src;
14
            foreach ($parts as $part) {
15
                if (isset($res[$part])) {
16
                    $res = $res[$part];
17
                } else {
18
                    return $res;
19
                }
20
            }
21
            return $res;
22
        } else {
23
            if (array_key_exists($fieldName, $this->src)) {
24
                return $this->src[$fieldName];
25
            } else {
26
                return null;
27
            }
28
        }
29
    }
30
}
31