Completed
Push — master ( 3a502e...661c35 )
by Steve
06:26 queued 02:16
created

RepeaterBuilder::setLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
nc 1
cc 1
eloc 2
nop 3
1
<?php
2
3
namespace StoutLogic\AcfBuilder;
4
5
class RepeaterBuilder extends FieldsBuilder
6
{
7
    public function __construct($name, $args = [])
8
    {
9
        $this->config = array_merge(
10
            [
11
                'key' => 'field_'.$name,
12
                'name' => $name,
13
                'label' => $this->generateLabel($name),
14
                'type' => 'repeater',
15
            ],
16
            $args
17
        );
18
    }
19
20
    public function build()
21
    {
22
        $config = parent::build();
23
        $config['sub_fields'] = $config['fields'];
24
        unset($config['fields']);
25
        return $config;
26
    }
27
28
    public function endRepeater()
29
    {
30
        return $this->getParentContext();
31
    }
32
}
33