Test Failed
Push — main ( 9ff78e...4dc0dd )
by Paul
08:02
created

UnknownElement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
eloc 11
c 2
b 1
f 0
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A merge() 0 7 2
A build() 0 6 2
A tag() 0 6 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Html\FieldElements;
4
5
use GeminiLabs\SiteReviews\Modules\Html\Attributes;
6
7
class UnknownElement extends AbstractFieldElement
8
{
9
    public function build(array $overrideArgs = []): string
10
    {
11
        if (empty($this->tag())) {
12
            return '';
13
        }
14
        return parent::build($overrideArgs);
15
    }
16
17
    public function merge(): void
18
    {
19
        if (empty($this->tag())) {
20
            $this->field->is_valid = false;
21
            return;
22
        }
23
        parent::merge();
24
    }
25
26
    public function tag(): string
27
    {
28
        if (in_array($this->field->type, Attributes::INPUT_TYPES)) {
29
            return 'input';
30
        }
31
        return '';
32
    }
33
}
34