Passed
Push — master ( 817cab...57b58d )
by Paul
09:30 queued 02:21
created

Form::buildFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Html;
4
5
class Form
6
{
7
    /**
8
     * @param string $id
9
     * @return string
10
     */
11
    public function buildFields($id)
12
    {
13
        return array_reduce($this->getFields($id), function ($carry, $field) {
14
            return $carry.$field;
15
        });
16
    }
17
18
    /**
19
     * @param string $id
20
     * @return array
21
     */
22
    public function getFields($id)
23
    {
24
        $fields = [];
25
        foreach (glsr()->config('forms/'.$id) as $name => $field) {
26
            $fields[] = new Field(wp_parse_args($field, ['name' => $name]));
27
        }
28
        return $fields;
29
    }
30
31
    /**
32
     * @param string $id
33
     * @return void
34
     */
35
    public function renderFields($id)
36
    {
37
        echo $this->buildFields($id);
38
    }
39
}
40