FormMethodHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 3
1
<?php
2
3
namespace BeyondCode\TagHelper\Helpers;
4
5
use BeyondCode\TagHelper\Helper;
6
use BeyondCode\TagHelper\Html\HtmlElement;
7
8
class FormMethodHelper extends Helper
9
{
10
    protected $targetAttribute = 'method';
11
12
    protected $targetElement = 'form';
13
14
    public function process(HtmlElement $element)
15
    {
16
        $method = strtolower($element->getAttribute('method'));
17
18
        if ($method !== 'get' && $method !== 'post') {
19
            $element->setAttribute('method', 'post');
20
            $element->appendInnerText('<input type="hidden" name="_method" value="'.strtoupper($method).'" />');
21
        }
22
    }
23
}
24