Form::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
4
namespace Saimondev03;
5
6
use Illuminate\View\Component;
7
8
class Form extends Component
9
{
10
    /**
11
     * @var string
12
     */
13
    public $method;
14
15
    public function __construct(string $method = 'get')
16
    {
17
        $this->method = $method;
18
    }
19
20
    public function httpMethod()
21
    {
22
        if ($this->spoofedMethod()) {
23
            return 'post';
24
        }
25
26
        return $this->method;
27
    }
28
29
    public function spoofedMethod()
30
    {
31
        return in_array($this->method, ['put', 'patch', 'delete']);
32
    }
33
    public function render()
34
    {
35
        return view('saimondev03-form::form');
36
    }
37
}
38