Completed
Pull Request — 8.x-3.x (#503)
by Sebastian
03:44 queued 01:27
created

JsonHelper::decodeParams()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 1
nop 1
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql\Utility;
4
5
class JsonHelper {
6
7
  /**
8
   * @param array $values
9
   *
10
   * @return array
11
   */
12
  public static function decodeParams(array $values = []) {
13
    return array_map(function($value) {
14
      if (!is_string($value)) {
15
        return $value;
16
      }
17
18
      if (($decoded = json_decode($value, TRUE)) !== NULL && $decoded != $value) {
19
        return static::decodeParams($decoded);
20
      }
21
22
      return $value;
23
    }, $values);
24
  }
25
26
}