Passed
Push — 5.0.0 ( dd8bc0...b0cec2 )
by Fèvre
05:00
created

Textarea   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A errorFieldName() 0 3 1
A modelName() 0 3 1
A render() 0 3 1
A __construct() 0 12 1
1
<?php
2
3
namespace Xetaravel\View\Components;
4
5
use Closure;
6
use Illuminate\Contracts\View\View;
7
use Illuminate\View\Component;
8
9
class Textarea extends Component
10
{
11
    public string $uuid;
12
13
    public function __construct(
14
        public ?string $label = null,
15
        public ?string $hint = null,
16
        public ?string $hintClass = 'fieldset-label',
17
        public ?bool $inline = false,
18
19
        // Validations
20
        public ?string $errorClass = 'text-error',
21
        public ?bool $omitError = false,
22
        public ?bool $firstErrorOnly = false,
23
    ) {
24
        $this->uuid = md5(serialize($this));
25
    }
26
27
    public function modelName(): ?string
28
    {
29
        return $this->attributes->whereStartsWith('wire:model')->first();
30
    }
31
32
    public function errorFieldName(): ?string
33
    {
34
        return $this->modelName() ?? $this->attributes->whereStartsWith('name')->first();
35
    }
36
37
    /**
38
     * Get the view / contents that represent the component.
39
     */
40
    public function render(): View|Closure|string
41
    {
42
        return view('components.textarea');
43
    }
44
}
45