Completed
Pull Request — master (#4)
by Nick
05:39
created

Utility   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 27
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A arrayDepth() 0 15 4
1
<?php
2
3
namespace Acquia\LiftClient\Utility;
4
5
6
class Utility {
7
8
  /**
9
   * Define the Depth of an array.
10
   * Proudly found elsewhere
11
   * @see http://stackoverflow.com/a/262944/3664381
12
   * @param array $array
13
   * @return int
14
   */
15 6
  public static function arrayDepth(array $array) {
16 6
    $max_depth = 1;
17
18 6
    foreach ($array as $value) {
19 6
      if (is_array($value)) {
20
        $depth = Utility::arrayDepth($value) + 1;
21
22
        if ($depth > $max_depth) {
23 2
          $max_depth = $depth;
24
        }
25
      }
26 4
    }
27
28 6
    return $max_depth;
29
  }
30
31
32
}