Completed
Branch develop (6833e5)
by Steve
04:32
created

IterativeTransform::shouldRecurse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 2
1
<?php
2
3
namespace StoutLogic\AcfBuilder\Transform;
4
5
/**
6
 * Transform applies to all leafs in array at a single field level,
7
 * it doesn't recurse down fields, sub_fields or layouts.
8
 */
9
abstract class IterativeTransform extends RecursiveTransform
10
{
11
    /**
12
     * Define a list of array keys `transform` should not be recursed upon.
13
     * @var array
14
     */
15
   protected $dontRecurseKeys = ['fields', 'sub_fields', 'layouts'];
16
17
   protected function shouldRecurse($value, $key)
18
   {
19
       return is_array($value) && !in_array($key, $this->dontRecurseKeys, true);
20
   }
21
}
22