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

Textarea::modelName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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