Completed
Push — master ( 936da0...f7c12a )
by Pascal
14:46 queued 13:50
created

Component::isWired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ProtoneMedia\LaravelFormComponents\Components;
4
5
use Illuminate\Support\Str;
6
use Illuminate\View\Component as BaseComponent;
7
use ProtoneMedia\LaravelFormComponents\FormDataBinder;
8
9
abstract class Component extends BaseComponent
10
{
11
    /**
12
     * {@inheritDoc}
13
     */
14
    public function render()
15
    {
16
        $alias = Str::kebab(class_basename($this));
17
18
        $config = config("form-components.components.{$alias}");
19
20
        $framework = config("form-components.framework");
21
22
        return str_replace('{framework}', $framework, $config['view']);
23
    }
24
25
    /**
26
     * Returns a boolean wether the form is wired to a Livewire component.
27
     *
28
     * @return boolean
29
     */
30
    public function isWired(): bool
31
    {
32
        return app(FormDataBinder::class)->isWired();
33
    }
34
35
    /**
36
     * The inversion of 'isWired()'.
37
     *
38
     * @return boolean
39
     */
40
    public function isNotWired(): bool
41
    {
42
        return !$this->isWired();
43
    }
44
}
45