Completed
Push — master ( 445c40...d916d6 )
by Jelle
04:38
created

EntityPropertyUtil::getRawValue()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 8.8571
cc 5
eloc 9
nc 3
nop 1
crap 5
1
<?php
2
3
/**
4
 * @file
5
 * Contains \TheSportsDb\Entity\EntityPropertyUtil;
6
 */
7
8
namespace TheSportsDb\Entity;
9
10
/**
11
 * Utility class.
12
 *
13
 * @author Jelle Sebreghts
14
 */
15
class EntityPropertyUtil {
16
17
  /**
18
   * Get the raw value of any value.
19
   *
20
   * @param mixed $val
21
   *   The value to get the raw value of.
22
   *
23
   * @return mixed
24
   *   The raw value.
25
   */
26 1
  public static function getRawValue($val) {
27 1
    $return = $val;
28 1
    if (method_exists($val, 'raw')) {
29 1
      $return = $val->raw();
30
    }
31 1
    elseif (is_array($val)) {
32 1
      $return = array();
33 1
      foreach ($val as $v) {
34 1
        $return[] = method_exists($v, 'raw') ? $v->raw() : $v;
35
      }
36
    }
37 1
    return $return;
38
  }
39
}
40