TMethod::setMethod()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace kalanis\kw_forms\Form;
4
5
6
use kalanis\kw_input\Interfaces\IEntry;
7
8
9
/**
10
 * Trait TMethod
11
 * @package kalanis\kw_forms\Form
12
 * Trait to processing methods of form
13
 */
14
trait TMethod
15
{
16
    /**
17
     * Set transfer method of form
18
     * @param string $param
19
     */
20 9
    public function setMethod(string $param): void
21
    {
22 9
        if (in_array($param, [IEntry::SOURCE_GET, IEntry::SOURCE_POST, IEntry::SOURCE_CLI, IEntry::SOURCE_JSON])) {
23 9
            $this->setAttribute('method', $param);
24
        }
25 9
    }
26
27
    /**
28
     * Get that method
29
     * @return string
30
     */
31 9
    public function getMethod(): string
32
    {
33 9
        return strval($this->getAttribute('method'));
34
    }
35
36
    abstract public function setAttribute(string $name, string $value): void;
37
38
    abstract public function removeAttribute(string $name): void;
39
40
    abstract public function getAttribute(string $name): ?string;
41
}
42