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

Form   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 33
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A renderFields() 0 3 1
A getFields() 0 7 2
A buildFields() 0 4 1
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